You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "JoonaHa (via GitHub)" <gi...@apache.org> on 2023/11/28 17:24:32 UTC
[I] bug: response-rewrite filters.regex does not apply when content-encoding: gzip [apisix]
JoonaHa opened a new issue, #10562:
URL: https://github.com/apache/apisix/issues/10562
### Current Behavior
I have an APISIX route that uses `proxy-rewrite` to proxy users to specific endpoint. The endpoint response is a JSON payload with content headers `Content-Type: application/json` and `content-encoding: gzip`.
When I add `response-rewrite` plugin with `filters.regex` APISIX drops the `content-encoding: gzip` header. When I add the header back manually using `response-rewrite`'s `headers.add` functionality, the `filters.regex` replacement is not applied.
Here is my route configuration with placeholder urls:
```json
{
"id":"testroute",
"methods":[
"GET"
],
"plugins":{
"proxy-rewrite":{
"uri":"/specific/path",
"host":"example.org"
},
"response-rewrite":{
"headers":{
"add":[
"content-encoding: gzip"
]
},
"filters":[
{
"regex":"conformsTo",
"scope":"global",
"replace":"replacedvalue"
}
],
"vars":[
[
"status",
"==",
200
]
]
}
},
"upstream":{
"type":"roundrobin",
"scheme":"https",
"nodes":{
"example.org:443":1
}
},
"uri":"/testroute"
}
```
### Expected Behavior
Upstream's `content-encoding: gzip` header is passed normally trough APISIX and `response-rewrite`'s `filters.regex` is applied to the response JSON.
### Error Logs
_No response_
### Steps to Reproduce
1. Have an endpoint which responds with headers: `Content-Type: application/json` and `content-encoding: gzip`
2. Make a APISIX route with proxy-rewrite and response-rewrite
3. See if response-rewrite is applied with correct encoding headers.
### Environment
APISIX Docker image apache/apisix:3.7.0-debian
--
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
Re: [I] bug: response-rewrite filters.regex does not apply when content-encoding: gzip [apisix]
Posted by "yuweizzz (via GitHub)" <gi...@apache.org>.
yuweizzz commented on issue #10562:
URL: https://github.com/apache/apisix/issues/10562#issuecomment-1831772928
use `"Accept-Encoding": ""` tell upstream don't compress the payload, it need to work with `proxy-rewrite`, the another way is disable compression on upstream, it doesn't need a new header.
--
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
Re: [I] bug: response-rewrite filters.regex does not apply when content-encoding: gzip [apisix]
Posted by "JoonaHa (via GitHub)" <gi...@apache.org>.
JoonaHa commented on issue #10562:
URL: https://github.com/apache/apisix/issues/10562#issuecomment-1831820995
@yuweizzz By default APISIX seems to accepts gzip encoded data so the ideal situation would be for `response-rewrite` to also support different encoding methods.
Or at least mention the limitations of `response-rewrite` in the documentation.
--
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
Re: [I] bug: response-rewrite filters.regex does not apply when content-encoding: gzip [apisix]
Posted by "JoonaHa (via GitHub)" <gi...@apache.org>.
JoonaHa commented on issue #10562:
URL: https://github.com/apache/apisix/issues/10562#issuecomment-1831618411
For a workaround I used `proxy-rewrite`'s `headers` to set `Accept-Encoding` to an empty value so the upstream server doesn't respond with an compressed payload.
```json
{
"id":"testroute",
"methods":[
"GET"
],
"plugins":{
"proxy-rewrite":{
"uri":"/specific/path",
"host":"example.org",
"headers":{
"Accept-Encoding": ""
}
},
"response-rewrite":{
"filters":[
{
"regex":"conformsTo",
"scope":"global",
"replace":"replacedvalue"
}
],
"vars":[
[
"status",
"==",
200
]
]
}
},
"upstream":{
"type":"roundrobin",
"scheme":"https",
"nodes":{
"example.org:443":1
}
},
"uri":"/testroute"
}
```
--
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
Re: [I] bug: response-rewrite filters.regex does not apply when content-encoding: gzip [apisix]
Posted by "yuweizzz (via GitHub)" <gi...@apache.org>.
yuweizzz commented on issue #10562:
URL: https://github.com/apache/apisix/issues/10562#issuecomment-1831159562
In my options, when upstream return `content-encoding` means the body has been compressed, so the `filters.regex` may not work it the compressed body, manually using response-rewrite's headers.add should not work.
--
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
Re: [I] bug: response-rewrite filters.regex does not apply when content-encoding: gzip [apisix]
Posted by "shreemaan-abhishek (via GitHub)" <gi...@apache.org>.
shreemaan-abhishek commented on issue #10562:
URL: https://github.com/apache/apisix/issues/10562#issuecomment-1831356455
this isn't a bug, but gzip encoded data isn't supported for rewrite.
--
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
Re: [I] bug: response-rewrite filters.regex does not apply when content-encoding: gzip [apisix]
Posted by "yuweizzz (via GitHub)" <gi...@apache.org>.
yuweizzz commented on issue #10562:
URL: https://github.com/apache/apisix/issues/10562#issuecomment-1831406766
I want to try it, assign this issue to me?
--
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
Re: [I] bug: response-rewrite filters.regex does not apply when content-encoding: gzip [apisix]
Posted by "JoonaHa (via GitHub)" <gi...@apache.org>.
JoonaHa commented on issue #10562:
URL: https://github.com/apache/apisix/issues/10562#issuecomment-1831382171
Thank you for checking. I would have presumed that Apisix would handle different kind of content-encoding settings under the hood, so this feature would be much appreciated.
--
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
Re: [I] bug: response-rewrite filters.regex does not apply when content-encoding: gzip [apisix]
Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 closed issue #10562: bug: response-rewrite filters.regex does not apply when content-encoding: gzip
URL: https://github.com/apache/apisix/issues/10562
--
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
Re: [I] bug: response-rewrite filters.regex does not apply when content-encoding: gzip [apisix]
Posted by "yongxiaodong (via GitHub)" <gi...@apache.org>.
yongxiaodong commented on issue #10562:
URL: https://github.com/apache/apisix/issues/10562#issuecomment-1833354064
interesting
--
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
Re: [I] bug: response-rewrite filters.regex does not apply when content-encoding: gzip [apisix]
Posted by "yuweizzz (via GitHub)" <gi...@apache.org>.
yuweizzz commented on issue #10562:
URL: https://github.com/apache/apisix/issues/10562#issuecomment-1831777095
Do you think we still need to support encoded data in `response-rewrite`? @shreemaan-abhishek @JoonaHa
--
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
Re: [I] bug: response-rewrite filters.regex does not apply when content-encoding: gzip [apisix]
Posted by "monkeyDluffy6017 (via GitHub)" <gi...@apache.org>.
monkeyDluffy6017 commented on issue #10562:
URL: https://github.com/apache/apisix/issues/10562#issuecomment-1866191580
@JoonaHa please help to review https://github.com/apache/apisix/pull/10637
--
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