apache / apache/apisix-java-plugin-runner
request help: Client send Accept header value is overriden when set accept value in filter method
- Linguagem predominante
- Java
- Estrelas
- 152
- Forks
- 102
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Descrição
### 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
Guia de contribuição
Nenhum guia de contribuição indexado para este repositório
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- java
- Domínio
- api, backend
- Tipo de issue
- Bug
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Estagnada
- Clareza
- Precisa de esclarecimento
- Facilidade para iniciantes
- 35/100