You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/11/24 01:01:16 UTC

[GitHub] [apisix] seowjin1060 opened a new issue, #8388: bug: APISIX transform content-type from upstream response

seowjin1060 opened a new issue, #8388:
URL: https://github.com/apache/apisix/issues/8388

   ### Current Behavior
   
   
   Bug : Apisix converts reponse  content types to plain/text
   
   Testing with local apisix & test api server env  (apisix on 9080 port , test api server with 8000 port )
   
   - Json response if request sended  directly to test api server 
   <img width="580" alt="image" src="https://user-images.githubusercontent.com/26168539/203670033-dde8de39-8bc6-4019-9a4b-2f263f4146c5.png">
   
   - Converted to plain/text if request sended via apisix upstream 
   ![image](https://user-images.githubusercontent.com/26168539/203670700-fb211f5b-b867-4763-8552-6ec8ce73194d.png)
   
   Cause many type of api servers handled by apisix, some of them don't handle http response with json automatically,
   
   I expecting apisix not to convert response types to text/plain.
   
   Any approach or opinion will be appreciated to fix this problems 
   
   
   
   ### Expected Behavior
   
   Content type must be consist after handled by apisix upstream.
   
   
   
   
   
   ### Error Logs
   
   This seems to logical problem with apisix core, so no error logs included
   
   ### Steps to Reproduce
   
   1. send request to upstream via apisix server with Content-types: application/json header 
   
   2. check content types converted to plain/text
   ![image](https://user-images.githubusercontent.com/26168539/203670794-c25b4661-40ec-4b45-ba38-a17b2b48d6e0.png)
   
   
   ### Environment
   
   - APISIX version (run `apisix version`): 2.99
   - Operating system (run `uname -a`): RHEL 8
   - OpenResty / Nginx version (run `openresty -V` or `nginx -V`): 1.21.4
   - etcd version, if relevant (run `curl http://127.0.0.1:9090/v1/server_info`): 3.5.4
   - APISIX Dashboard version, if relevant: 2.13.0
   - Plugin runner version, for issues related to plugin runners: java 17
   - LuaRocks version, for installation issues (run `luarocks --version`):  5.4.4
   


-- 
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: notifications-unsubscribe@apisix.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] mscb402 commented on issue #8388: bug: APISIX converts content-type from upstream response

Posted by GitBox <gi...@apache.org>.
mscb402 commented on issue #8388:
URL: https://github.com/apache/apisix/issues/8388#issuecomment-1326214965

   Sorry, I try this on my local, but I can't make this happen again on my local. Please share your config. It depends on how you 
   upstream response.


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] ZChengjin commented on issue #8388: bug: external-plugin-post-resp plugin converts content-type from upstream response

Posted by GitBox <gi...@apache.org>.
ZChengjin commented on issue #8388:
URL: https://github.com/apache/apisix/issues/8388#issuecomment-1365720854

   I also encountered this problem, is there a solution now?


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] yunduansing commented on issue #8388: bug: external-plugin-post-resp plugin converts content-type from upstream response

Posted by GitBox <gi...@apache.org>.
yunduansing commented on issue #8388:
URL: https://github.com/apache/apisix/issues/8388#issuecomment-1367045079

   
   > I also encountered this problem, is there a solution now?
   
   You can try enable the official "response-rewrite" plugin and config headers.set: Content-Type can solve this problem:
   `"headers": {
       "set": {
         "Content-Type": "application/json; charset=utf-8"
       }
     }`
   
   ![image](https://user-images.githubusercontent.com/11469334/209898551-64d0bc93-f94c-472f-90c6-463a61a11fb2.png)


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] spacewander commented on issue #8388: bug: external-plugin-post-resp plugin converts content-type from upstream response

Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #8388:
URL: https://github.com/apache/apisix/issues/8388#issuecomment-1369414734

   > In fact, I don't think we should restrict any modification of response headers, after all the response-rewrite plugin does not have any restrictions. cc @spacewander
   
   LGTM


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] seowjin1060 commented on issue #8388: bug: APISIX converts content-type from upstream response

Posted by GitBox <gi...@apache.org>.
seowjin1060 commented on issue #8388:
URL: https://github.com/apache/apisix/issues/8388#issuecomment-1326056551

   Yes, that status code is from upstream target, not from apisix. 
   So upstream responses with 200 code may affected with this issue, cause upstream response seems to be encoded with text/html via apisix.
   
   Here's sample request to test server with 200 response code
   ![image](https://user-images.githubusercontent.com/26168539/203720212-54eaf10a-44d9-4ce5-8151-ee8020f642f5.png)
   
   
   


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] mscb402 commented on issue #8388: bug: APISIX converts content-type from upstream response

Posted by GitBox <gi...@apache.org>.
mscb402 commented on issue #8388:
URL: https://github.com/apache/apisix/issues/8388#issuecomment-1326025374

   In your case, this is HTTP 500 status. Please try to test the HTTP 200 status upstream. Is 200 status still have this problem?


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] soulbird commented on issue #8388: bug: external-plugin-post-resp plugin converts content-type from upstream response

Posted by GitBox <gi...@apache.org>.
soulbird commented on issue #8388:
URL: https://github.com/apache/apisix/issues/8388#issuecomment-1345741536

   Looks like a bug, the ext-plugin-post-resp plugin ignores the upstream content-type response header. refer: https://github.com/apache/apisix/blob/master/apisix/plugins/ext-plugin/init.lua#L804-L809


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] WangSZ commented on issue #8388: bug: external-plugin-post-resp plugin converts content-type from upstream response

Posted by GitBox <gi...@apache.org>.
WangSZ commented on issue #8388:
URL: https://github.com/apache/apisix/issues/8388#issuecomment-1345499119

   I have a similar problem that plugin-post-resp plugin changed upstream headers such as "Content-Type ,Access-Control-Allow-Origin,Access-Control-Allow-Credentials". The upstream is http://[httpbin.org](http://httpbin.org/)/
   
   
   ![image](https://user-images.githubusercontent.com/1385039/206895291-6d17af93-b928-4667-b8ab-016a9a74c474.png)
   
   


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] mscb402 commented on issue #8388: bug: APISIX converts content-type from upstream response

Posted by GitBox <gi...@apache.org>.
mscb402 commented on issue #8388:
URL: https://github.com/apache/apisix/issues/8388#issuecomment-1325829090

   Or disable HTTPS on your apisix route


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] yunduansing commented on issue #8388: bug: external-plugin-post-resp plugin converts content-type from upstream response

Posted by GitBox <gi...@apache.org>.
yunduansing commented on issue #8388:
URL: https://github.com/apache/apisix/issues/8388#issuecomment-1345935684

   I met the problem too
   ![image](https://user-images.githubusercontent.com/11469334/206971531-3422d471-b5ca-4f8b-84e5-a733ad0e8650.png)
   


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] soulbird commented on issue #8388: bug: external-plugin-post-resp plugin converts content-type from upstream response

Posted by GitBox <gi...@apache.org>.
soulbird commented on issue #8388:
URL: https://github.com/apache/apisix/issues/8388#issuecomment-1367762816

   In fact, I don't think we should restrict any modification of response headers, after all the response-rewrite plugin does not have any restrictions.  cc @spacewander 


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] soulbird commented on issue #8388: bug: external-plugin-post-resp plugin converts content-type from upstream response

Posted by GitBox <gi...@apache.org>.
soulbird commented on issue #8388:
URL: https://github.com/apache/apisix/issues/8388#issuecomment-1366452755

   > I also encountered this problem, is there a solution now?
   
   We can try to remove https://github.com/apache/apisix/blob/master/apisix/plugins/ext-plugin/init.lua#L79


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] spacewander closed issue #8388: bug: external-plugin-post-resp plugin converts content-type from upstream response

Posted by GitBox <gi...@apache.org>.
spacewander closed issue #8388: bug: external-plugin-post-resp plugin converts content-type from upstream response
URL: https://github.com/apache/apisix/issues/8388


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] edisonX-sudo commented on issue #8388: bug: external-plugin-post-resp plugin converts content-type from upstream response

Posted by "edisonX-sudo (via GitHub)" <gi...@apache.org>.
edisonX-sudo commented on issue #8388:
URL: https://github.com/apache/apisix/issues/8388#issuecomment-1669371464

   > I also encountered this problem, is there a solution now?
   
   could be solved in this way
   ```go
   ...
   func (ri *ResponseI18n2) ResponseFilter(conf interface{}, w pkgHTTP.Response) {
   	respHeader := w.Header()
   	contentType := respHeader.Get("Content-Type")
   	respHeader.Set("X-Content-Type", contentType)
           ...
   }
   ...
   ```
   ```apisix config
   ...
    "response-rewrite": {
         "_meta": {
           "disable": false
         },
         "headers": {
           "set": {
             "Content-Type": "$sent_http_x_content_type"
           }
         }
       }
   ...
   ``` 


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] seowjin1060 commented on issue #8388: bug: external-plugin-post-resp plugin converts content-type from upstream response

Posted by GitBox <gi...@apache.org>.
seowjin1060 commented on issue #8388:
URL: https://github.com/apache/apisix/issues/8388#issuecomment-1367738142

   > > I also encountered this problem, is there a solution now?
   > 
   > We can try to remove https://github.com/apache/apisix/blob/master/apisix/plugins/ext-plugin/init.lua#L79
   
   HI there, how about deleting content-encoding also? 
   Seems that causing charset fixed to utf-8.
   Checked working normally if content-type / charset deleted from excluded header.
   
   And I'll look into case if we are using post-response runner to use response from plugin. Because deleting excluded header will need to be writing requested header on runner response (postresponsefilter).


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] seowjin1060 commented on issue #8388: bug: APISIX converts content-type from upstream response

Posted by GitBox <gi...@apache.org>.
seowjin1060 commented on issue #8388:
URL: https://github.com/apache/apisix/issues/8388#issuecomment-1325994400

   > Or disable HTTPS on your apisix route
   
   Thank you for reply, there are some difference between sample and production environment. So 302 was appeared.
   
   I updated example to production which 302 status was not appeared but content type was converted to text/plain.
   
   And, Here's Route configuration tends to keep http method for each request.
   ![image](https://user-images.githubusercontent.com/26168539/203706245-7688f694-7cdd-4538-af37-9ee3582e715e.png)
   


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix] mscb402 commented on issue #8388: bug: APISIX converts content-type from upstream response

Posted by GitBox <gi...@apache.org>.
mscb402 commented on issue #8388:
URL: https://github.com/apache/apisix/issues/8388#issuecomment-1325827984

   Because there's a 302 status response. Maybe you can try accessing using HTTPS.
   `curl -v -H "Accept: application/json" https://localhost:9443/mlc`


-- 
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: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org