apache / apache/apisix-java-plugin-runner
request help: Client send Accept header value is overriden when set accept value in filter method
- 主要語言
- Java
- 星號
- 152
- 分支
- 102
- PR 合併指標
- 30 天內沒有已合併 PR
描述
### 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
貢獻指南
這個儲存庫沒有索引到貢獻指南
研究方向
Start by tracing the filter and postFilter entry points described in the issue, along with NginxVars.HTTP_ACCEPT and the request header accessors. Reproduce the blank Accept-header case on version 0.4.0 and compare the value before and after filter processing. Done means the client-sent blank value remains available in postFilter while the upstream Accept value can still be set.
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- java
- 領域
- api, backend
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 35/100