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 2020/08/03 11:04:50 UTC
[GitHub] [apisix] taotao2014 opened a new pull request #1978: add core.request.get_scheme/host/port/http_version
taotao2014 opened a new pull request #1978:
URL: https://github.com/apache/apisix/pull/1978
### What this PR does / why we need it:
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->
### Pre-submission checklist:
* [ ] Did you explain what problem does this PR solve? Or what new features have been added?
* [ ] Have you added corresponding test cases?
* [ ] Have you modified the corresponding document?
* [ ] Is this PR backward compatible?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] membphis commented on pull request #1978: add core.request.get_scheme/host/port/http_version
Posted by GitBox <gi...@apache.org>.
membphis commented on pull request #1978:
URL: https://github.com/apache/apisix/pull/1978#issuecomment-667963880
we should keep those codes.

----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] taotao2014 commented on pull request #1978: add core.request.get_scheme/host/port/http_version
Posted by GitBox <gi...@apache.org>.
taotao2014 commented on pull request #1978:
URL: https://github.com/apache/apisix/pull/1978#issuecomment-668050385
What can i do ? Adding it has conflicts
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] membphis commented on a change in pull request #1978: add core.request.get_scheme/host/port/http_version
Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1978:
URL: https://github.com/apache/apisix/pull/1978#discussion_r464450574
##########
File path: t/core/request.t
##########
@@ -206,3 +206,151 @@ X-Forwarded-For: 10.0.0.1
10.0.0.1
--- no_error_log
[error]
+
+
+
+=== TEST 6: get_host
+--- config
+ location = /hello {
+ real_ip_header X-Real-IP;
+
+ set_real_ip_from 0.0.0.0/0;
+ set_real_ip_from ::/0;
+ set_real_ip_from unix:;
+
+ access_by_lua_block {
+ local core = require("apisix.core")
+ local ngx_ctx = ngx.ctx
+ local api_ctx = ngx_ctx.api_ctx
+ if api_ctx == nil then
+ api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
+ ngx_ctx.api_ctx = api_ctx
+ end
+
+ core.ctx.set_vars_meta(api_ctx)
+ }
+ content_by_lua_block {
+ local core = require("apisix.core")
+ local host = core.request.get_host(ngx.ctx.api_ctx)
+ ngx.say(host)
+ }
+ }
+--- request
+GET /hello
+--- more_headers
+X-Real-IP: 10.0.0.1
+--- response_body
+localhost
+--- no_error_log
+[error]
+
+
+
+=== TEST 7: get_scheme
+--- config
+ location = /hello {
+ real_ip_header X-Real-IP;
+
+ set_real_ip_from 0.0.0.0/0;
+ set_real_ip_from ::/0;
+ set_real_ip_from unix:;
+
+ access_by_lua_block {
+ local core = require("apisix.core")
+ local ngx_ctx = ngx.ctx
+ local api_ctx = ngx_ctx.api_ctx
+ if api_ctx == nil then
+ api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
+ ngx_ctx.api_ctx = api_ctx
+ end
+
+ core.ctx.set_vars_meta(api_ctx)
+ }
+ content_by_lua_block {
+ local core = require("apisix.core")
+ local scheme = core.request.get_scheme(ngx.ctx.api_ctx)
+ ngx.say(scheme)
+ }
+ }
+--- request
+GET /hello
+--- more_headers
+X-Real-IP: 10.0.0.1
+--- response_body
+http
+--- no_error_log
+[error]
+
+
+
+=== TEST 8: get_port
+--- config
+ location = /hello {
+ real_ip_header X-Real-IP;
+
+ set_real_ip_from 0.0.0.0/0;
+ set_real_ip_from ::/0;
+ set_real_ip_from unix:;
+
+ access_by_lua_block {
+ local core = require("apisix.core")
+ local ngx_ctx = ngx.ctx
+ local api_ctx = ngx_ctx.api_ctx
+ if api_ctx == nil then
+ api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
+ ngx_ctx.api_ctx = api_ctx
+ end
+
+ core.ctx.set_vars_meta(api_ctx)
+ }
+ content_by_lua_block {
+ local core = require("apisix.core")
+ local port = core.request.get_port(ngx.ctx.api_ctx)
+ ngx.say(port)
+ }
+ }
+--- request
+GET /hello
+--- more_headers
+X-Real-IP: 10.0.0.1
+--- response_body
+1984
+--- no_error_log
+[error]
+
+
+
+=== TEST 9: get_http_version
+--- config
+ location = /hello {
+ real_ip_header X-Real-IP;
+
+ set_real_ip_from 0.0.0.0/0;
+ set_real_ip_from ::/0;
+ set_real_ip_from unix:;
+
+ access_by_lua_block {
+ local core = require("apisix.core")
+ local ngx_ctx = ngx.ctx
+ local api_ctx = ngx_ctx.api_ctx
+ if api_ctx == nil then
+ api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
+ ngx_ctx.api_ctx = api_ctx
+ end
+
+ core.ctx.set_vars_meta(api_ctx)
+ }
+ content_by_lua_block {
+ local core = require("apisix.core")
+ local http_version = core.request.get_http_version()
+ ngx.say(http_version)
+ }
+ }
+--- request
+GET /hello
+--- more_headers
+X-Real-IP: 10.0.0.1
+--- response_body
+1.1
+--- no_error_log
+[error]
Review comment:
please add a blank line at the end of file
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] membphis merged pull request #1978: add core.request.get_scheme/host/port/http_version
Posted by GitBox <gi...@apache.org>.
membphis merged pull request #1978:
URL: https://github.com/apache/apisix/pull/1978
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] membphis commented on pull request #1978: add core.request.get_scheme/host/port/http_version
Posted by GitBox <gi...@apache.org>.
membphis commented on pull request #1978:
URL: https://github.com/apache/apisix/pull/1978#issuecomment-668052316
> What can i do ? Adding it has conflicts
if you do not know how to fix it, you can create a new PR with your new code. then we can close this stale PR.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] membphis commented on pull request #1978: add core.request.get_scheme/host/port/http_version
Posted by GitBox <gi...@apache.org>.
membphis commented on pull request #1978:
URL: https://github.com/apache/apisix/pull/1978#issuecomment-668054340
> What can i do ? Adding it has conflicts
I helped you fix this case. you can continue your job.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] membphis removed a comment on pull request #1978: add core.request.get_scheme/host/port/http_version
Posted by GitBox <gi...@apache.org>.
membphis removed a comment on pull request #1978:
URL: https://github.com/apache/apisix/pull/1978#issuecomment-668052316
> What can i do ? Adding it has conflicts
if you do not know how to fix it, you can create a new PR with your new code. then we can close this stale PR.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] taotao2014 commented on a change in pull request #1978: add core.request.get_scheme/host/port/http_version
Posted by GitBox <gi...@apache.org>.
taotao2014 commented on a change in pull request #1978:
URL: https://github.com/apache/apisix/pull/1978#discussion_r464732721
##########
File path: t/core/request.t
##########
@@ -206,3 +206,151 @@ X-Forwarded-For: 10.0.0.1
10.0.0.1
--- no_error_log
[error]
+
+
+
+=== TEST 6: get_host
+--- config
+ location = /hello {
+ real_ip_header X-Real-IP;
+
+ set_real_ip_from 0.0.0.0/0;
+ set_real_ip_from ::/0;
+ set_real_ip_from unix:;
+
+ access_by_lua_block {
+ local core = require("apisix.core")
+ local ngx_ctx = ngx.ctx
+ local api_ctx = ngx_ctx.api_ctx
+ if api_ctx == nil then
+ api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
+ ngx_ctx.api_ctx = api_ctx
+ end
+
+ core.ctx.set_vars_meta(api_ctx)
+ }
+ content_by_lua_block {
+ local core = require("apisix.core")
+ local host = core.request.get_host(ngx.ctx.api_ctx)
+ ngx.say(host)
+ }
+ }
+--- request
+GET /hello
+--- more_headers
+X-Real-IP: 10.0.0.1
+--- response_body
+localhost
+--- no_error_log
+[error]
+
+
+
+=== TEST 7: get_scheme
+--- config
+ location = /hello {
+ real_ip_header X-Real-IP;
+
+ set_real_ip_from 0.0.0.0/0;
+ set_real_ip_from ::/0;
+ set_real_ip_from unix:;
+
+ access_by_lua_block {
+ local core = require("apisix.core")
+ local ngx_ctx = ngx.ctx
+ local api_ctx = ngx_ctx.api_ctx
+ if api_ctx == nil then
+ api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
+ ngx_ctx.api_ctx = api_ctx
+ end
+
+ core.ctx.set_vars_meta(api_ctx)
+ }
+ content_by_lua_block {
+ local core = require("apisix.core")
+ local scheme = core.request.get_scheme(ngx.ctx.api_ctx)
+ ngx.say(scheme)
+ }
+ }
+--- request
+GET /hello
+--- more_headers
+X-Real-IP: 10.0.0.1
+--- response_body
+http
+--- no_error_log
+[error]
+
+
+
+=== TEST 8: get_port
+--- config
+ location = /hello {
+ real_ip_header X-Real-IP;
+
+ set_real_ip_from 0.0.0.0/0;
+ set_real_ip_from ::/0;
+ set_real_ip_from unix:;
+
+ access_by_lua_block {
+ local core = require("apisix.core")
+ local ngx_ctx = ngx.ctx
+ local api_ctx = ngx_ctx.api_ctx
+ if api_ctx == nil then
+ api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
+ ngx_ctx.api_ctx = api_ctx
+ end
+
+ core.ctx.set_vars_meta(api_ctx)
+ }
+ content_by_lua_block {
+ local core = require("apisix.core")
+ local port = core.request.get_port(ngx.ctx.api_ctx)
+ ngx.say(port)
+ }
+ }
+--- request
+GET /hello
+--- more_headers
+X-Real-IP: 10.0.0.1
+--- response_body
+1984
+--- no_error_log
+[error]
+
+
+
+=== TEST 9: get_http_version
+--- config
+ location = /hello {
+ real_ip_header X-Real-IP;
+
+ set_real_ip_from 0.0.0.0/0;
+ set_real_ip_from ::/0;
+ set_real_ip_from unix:;
+
+ access_by_lua_block {
+ local core = require("apisix.core")
+ local ngx_ctx = ngx.ctx
+ local api_ctx = ngx_ctx.api_ctx
+ if api_ctx == nil then
+ api_ctx = core.tablepool.fetch("api_ctx", 0, 32)
+ ngx_ctx.api_ctx = api_ctx
+ end
+
+ core.ctx.set_vars_meta(api_ctx)
+ }
+ content_by_lua_block {
+ local core = require("apisix.core")
+ local http_version = core.request.get_http_version()
+ ngx.say(http_version)
+ }
+ }
+--- request
+GET /hello
+--- more_headers
+X-Real-IP: 10.0.0.1
+--- response_body
+1.1
+--- no_error_log
+[error]
Review comment:
completed
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org