apache / apache/apisix-java-plugin-runner
request help: Client send Accept header value is overriden when set accept value in filter method
- Ngôn ngữ chính
- Java
- Star
- 152
- Fork
- 102
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
### Issue description
I'm accessing the Accept header value in filter and postFilter method.
Here's what I've experienced.
1. the client sends accept value as ` `(blank)
2. In the filter method, set accept value, for example `application/xml;charset=euc-kr`, to call an upstream server with that accept header value.
3. In the post filter method, access accept header value. and It turns out `application/xml;charset=euc-kr` not a ` `(blank)
It only happens when the client send accept header is ` `
Here's my code
```java
@Override
public void filter(HttpRequest request, HttpResponse response, PluginFilterChain chain) {
var config = getConfig(request.getConfig(this), ContentTypeConverterFilterConfig.class);
request.setHeader(HTTP_HEADER_ACCEPT, config.getUpstreamAccept()); // config.getUpstreamAccept() is `application/xml;charset=euc-kr`
request.setHeader(HTTP_OPENAPI_ORIGINAL_HEADER_ACCEPT,
getNonBlankHeaderValue(request.getVars(NginxVars.HTTP_ACCEPT.getValue()))); // I have to add another header value so that I can client send accept header value in postFilter method
chain.filter(request, response);
}
@Override
public void postFilter(PostRequest request, PostResponse response, PluginFilterChain chain) {
...
request.getVars(NginxVars.HTTP_ACCEPT.getValue()) // not a client send accept header value (` `)
...
}
public enum NginxVars {
HTTP_ACCEPT("http_accept"),
REQUEST_URI("request_uri");
...
```
### Environment
0.4.0
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.