Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] I want to modify the content-type of returning data, but the modified Content-Type cannot take effect #5594

Open
1 task done
creabob opened this issue Jul 9, 2024 · 3 comments
Labels
type: bug Something isn't working

Comments

@creabob
Copy link

creabob commented Jul 9, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

in this case, HTTP return json data, I want to change to the return format of XML, but the Content-Type cannot be modified.

Expected Behavior

i can change the response header in exchange,
exchange.getResponse().getHeaders().setContentType(xxx)

Steps To Reproduce

modify the body and header of response.
return changed body but the content-type of response header un-changed

Environment

ShenYu version(s):
master

Debug logs

No response

Anything else?

image content-type use single method to require, However, it is not obtained from exchange but from Attribute, image when i add this line code ,it can fix ,is it correct?
@creabob creabob added the type: bug Something isn't working label Jul 9, 2024
@moremind
Copy link
Member

what?

@creabob
Copy link
Author

creabob commented Jul 15, 2024

image in modifyResponse plugin, i add this conditions, image addKey success, but modify key failed .

@creabob
Copy link
Author

creabob commented Jul 19, 2024

当我修改返回值的header头时,content-type字段无法修改,无论是我自定义的插件还是modifyResponse插件,都不成功。
我修改的方式是加入这段代码
exchange.getResponse().getHeaders().setContentType(xxx)

当我debug时,发现content-type有单独的方法去获取,可是并不是通过exchange的值获取。
image
我想问,正确修改response的content-type方式是什么?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants