apache / apache/shenyu

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

Open
#5,594 3 comments 0 reactions 0 assignees View on GitHub
type: bug
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

### 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

```markdown
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?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the response handling path described in the issue: modify both the response body and headers through exchange.getResponse().getHeaders(), then compare the returned Content-Type with the requested XML format. Check why Content-Type is read from an Attribute instead of the exchange response headers; done means the modified response uses the new Content-Type consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.