tokers commented on code in PR #7401:
URL: https://github.com/apache/apisix/pull/7401#discussion_r917385709


##########
t/plugin/proxy-rewrite3.t:
##########
@@ -200,3 +200,103 @@ passed
 GET /hello
 --- error_log
 plugin_proxy_rewrite get method: POST
+
+
+
+=== TEST 8: set route(unsafe uri normalized at request)
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                 ngx.HTTP_PUT,
+                 [[{
+                        "methods": ["GET"],
+                        "plugins": {
+                            "proxy-rewrite": {
+                                "use_real_request_uri_unsafe": false
+                            }
+                        },
+                        "upstream": {
+                            "nodes": {
+                                "127.0.0.1:1980": 1
+                            },
+                            "type": "roundrobin"
+                        },
+                        "uri": "/print_uri_detailed_99"
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 9: unsafe uri normalized at request
+--- request
+GET /print%5Furi%5Fdetailed%5F99 HTTP/1.1
+--- response_body
+ngx.var.uri: /print_uri_detailed_99
+ngx.var.request_uri: /print_uri_detailed_99
+--- no_error_log
+[error]
+
+
+
+=== TEST 10: set route(unsafe uri not normalized at request)
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                 ngx.HTTP_PUT,
+                 [[{
+                        "methods": ["GET"],
+                        "plugins": {
+                            "proxy-rewrite": {
+                                "use_real_request_uri_unsafe": true
+                            }
+                        },
+                        "upstream": {
+                            "nodes": {
+                                "127.0.0.1:1980": 1
+                            },
+                            "type": "roundrobin"
+                        },
+                        "uri": "/print_uri_detailed_99"
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 11: unsafe uri not normalized at request
+--- request
+GET /print%5Furi%5Fdetailed%5F99 HTTP/1.1
+--- response_body
+ngx.var.uri: /print_uri_detailed_99
+ngx.var.request_uri: /print%5Furi%5Fdetailed%5F99
+--- no_error_log
+[error]

Review Comment:
   @soulbird The response body is returned by the upstream.



-- 
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