jiangfucheng commented on PR #9864: URL: https://github.com/apache/apisix/pull/9864#issuecomment-1646533082
https://github.com/apache/apisix/blob/59c1d99a6a571a77d9c3f7995a23785d93a4a92c/t/lib/ext-plugin.lua#L473C13-L473C13 Before this line, we can mock `rewrite_request_body` case: ``` elseif case.rewrite_request_body == true then local len = 4 http_req_call_rewrite.StartBodyVector(builder, len) builder:PrependByte(string.byte("\n")) builder:PrependByte(string.byte("c")) builder:PrependByte(string.byte("b")) builder:PrependByte(string.byte("a")) local b = builder:EndVector(len) http_req_call_rewrite.Start(builder) http_req_call_rewrite.AddBody(builder, b) local action = http_req_call_rewrite.End(builder) build_action(action, http_req_call_action.Rewrite) ``` And then, we can add test cases in `plugin/ext-plugin/http-req-call.t` ``` === TEST 27: add route --- config location /t { content_by_lua_block { local json = require("toolkit.json") local t = require("lib.test_admin") local code, message, res = t.test('/apisix/admin/routes/1', ngx.HTTP_PUT, [[{ "uri": "/echo", "plugins": { "ext-plugin-pre-req": { } }, "upstream": { "nodes": { "127.0.0.1:1980": 1 }, "type": "roundrobin" } }]] ) if code >= 300 then ngx.status = code ngx.say(message) return end ngx.say(message) } } --- response_body passed === TEST 29: test rewrite request body --- ONLY --- request GET /echo --- response_body chomp cat --- extra_stream_config server { listen unix:$TEST_NGINX_HTML_DIR/nginx.sock; content_by_lua_block { local ext = require("lib.ext-plugin") ext.go({rewrite_request_body = true}) } } --- response_body abc ``` -- 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]
