[GitHub] [apisix] spacewander commented on issue #5451: request help: Does response-rewrite plugin support partial or regular substitution
spacewander commented on issue #5451: URL: https://github.com/apache/apisix/issues/5451#issuecomment-1078560446 LGTM, except for a small problem: We need to check the result of `hold_body_chunk`: https://github.com/apache/apisix/blob/6cd7b8d024d2b3da9db0a61dbff3b462059fa233/apisix/core/response.lua#L168-L173 -- 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-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #5451: request help: Does response-rewrite plugin support partial or regular substitution
spacewander commented on issue #5451: URL: https://github.com/apache/apisix/issues/5451#issuecomment-1075804014 We can use https://github.com/apache/apisix/blob/9e1988595c7145babfaa9de36030f6540686c866/apisix/core/response.lua#L177 to buffer the body -- 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-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #5451: request help: Does response-rewrite plugin support partial or regular substitution
spacewander commented on issue #5451: URL: https://github.com/apache/apisix/issues/5451#issuecomment-1066083863 > On this way, filter would take effect orderly by itself, right? Yes. > I am afraid we can't do regex in the stream. Actually, I mean the streaming processing (not the L4 proxy). -- 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-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [apisix] spacewander commented on issue #5451: request help: Does response-rewrite plugin support partial or regular substitution
spacewander commented on issue #5451: URL: https://github.com/apache/apisix/issues/5451#issuecomment-1064724614 Well, personally I prefer to use an array of filters: ``` "filters": [{ "expr": ... # if given, run the filter when it's evaluated to true. Can be used to support "content-type" and more. "kind": "regex", # a string enum would be better "scope": ..., "pattern": ..., ... }] ``` > equals to 1 then fallback to completely substitute, otherwise goto regex substitute(both in header_filter and body_filter). "completely substitute" can be named as sub_filter substitute? As Nginx's sub_fitler supports variable, which isn't a plain substitute. > local body = ngx.arg[1] > ngx.arg[1] = sub(conf.filter_pattern, conf.filter_replace, conf.filter_options) I am afraid we can't do regex in the stream. This requires the regex engine to have stream mode, for example, see https://github.com/google/re2/issues/127. In fact, Nginx's sub_filter will buffer the data before substitution. -- 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-unsubscr...@apisix.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org