shenyu icon indicating copy to clipboard operation
shenyu copied to clipboard

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

Open creabob opened this issue 1 year ago • 3 comments

Is there an existing issue for this?

  • [X] 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 avatar Jul 09 '24 08:07 creabob

what?

moremind avatar Jul 13 '24 06:07 moremind

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

creabob avatar Jul 15 '24 01:07 creabob

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

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

creabob avatar Jul 19 '24 01:07 creabob