yujinchoi-94 opened a new issue, #251:
URL: https://github.com/apache/apisix-java-plugin-runner/issues/251

   ### Issue description
   I'm accessing 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
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to