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/07/31 03:56:03 UTC

[GitHub] [incubator-apisix] taotao2014 opened a new pull request #1953: add core.request.get_scheme/host/port/http_version

taotao2014 opened a new pull request #1953:
URL: https://github.com/apache/incubator-apisix/pull/1953


   ### 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] [incubator-apisix] taotao2014 commented on a change in pull request #1953: add core.request.get_scheme/host/port/http_version

Posted by GitBox <gi...@apache.org>.
taotao2014 commented on a change in pull request #1953:
URL: https://github.com/apache/incubator-apisix/pull/1953#discussion_r463622806



##########
File path: apisix/core/request.lua
##########
@@ -94,7 +94,34 @@ function _M.get_remote_client_port(ctx)
         ctx = ngx.ctx.api_ctx
     end
     return tonumber(ctx.var.remote_port)
-  end
+end
+
+function _M.get_scheme(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return ctx.var.scheme or ''
+end
+
+function _M.get_host(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return ctx.var.host or ''
+end
+
+function _M.get_port(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return tonumber(ctx.var.server_port)
+end
+
+function _M.get_http_version()
+
+    return ngx.req.http_version()
+

Review comment:
       removed




----------------------------------------------------------------
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] [incubator-apisix] taotao2014 commented on pull request #1953: add core.request.get_scheme/host/port/http_version

Posted by GitBox <gi...@apache.org>.
taotao2014 commented on pull request #1953:
URL: https://github.com/apache/incubator-apisix/pull/1953#issuecomment-667014825


   > @taotao2014 please fix conflicting files: apisix/core/request.lua
   
   Only those with write access to this repository can merge pull requests.


----------------------------------------------------------------
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] [incubator-apisix] membphis commented on a change in pull request #1953: add core.request.get_scheme/host/port/http_version

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1953:
URL: https://github.com/apache/incubator-apisix/pull/1953#discussion_r463489057



##########
File path: apisix/core/request.lua
##########
@@ -94,7 +94,34 @@ function _M.get_remote_client_port(ctx)
         ctx = ngx.ctx.api_ctx
     end
     return tonumber(ctx.var.remote_port)
-  end
+end
+
+function _M.get_scheme(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return ctx.var.scheme or ''
+end
+
+function _M.get_host(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return ctx.var.host or ''
+end
+
+function _M.get_port(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return tonumber(ctx.var.server_port)
+end
+
+function _M.get_http_version()

Review comment:
       I think `_M.get_http_version = ngx.req.http_version` is better, simpler and faster.




----------------------------------------------------------------
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] [incubator-apisix] moonming commented on pull request #1953: add core.request.get_scheme/host/port/http_version

Posted by GitBox <gi...@apache.org>.
moonming commented on pull request #1953:
URL: https://github.com/apache/incubator-apisix/pull/1953#issuecomment-666941881


   @taotao2014 please fix conflicting files: apisix/core/request.lua
   


----------------------------------------------------------------
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] [incubator-apisix] membphis commented on a change in pull request #1953: add core.request.get_scheme/host/port/http_version

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1953:
URL: https://github.com/apache/incubator-apisix/pull/1953#discussion_r463556815



##########
File path: apisix/core/request.lua
##########
@@ -94,7 +94,34 @@ function _M.get_remote_client_port(ctx)
         ctx = ngx.ctx.api_ctx
     end
     return tonumber(ctx.var.remote_port)
-  end
+end
+
+function _M.get_scheme(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return ctx.var.scheme or ''
+end
+
+function _M.get_host(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return ctx.var.host or ''
+end
+
+function _M.get_port(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return tonumber(ctx.var.server_port)
+end
+
+function _M.get_http_version()
+

Review comment:
       remove this blank line

##########
File path: apisix/core/request.lua
##########
@@ -94,7 +94,34 @@ function _M.get_remote_client_port(ctx)
         ctx = ngx.ctx.api_ctx
     end
     return tonumber(ctx.var.remote_port)
-  end
+end
+
+function _M.get_scheme(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return ctx.var.scheme or ''
+end
+
+function _M.get_host(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return ctx.var.host or ''
+end
+
+function _M.get_port(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return tonumber(ctx.var.server_port)
+end
+
+function _M.get_http_version()
+
+    return ngx.req.http_version()
+

Review comment:
       ditto




----------------------------------------------------------------
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] [incubator-apisix] membphis commented on a change in pull request #1953: add core.request.get_scheme/host/port/http_version

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1953:
URL: https://github.com/apache/incubator-apisix/pull/1953#discussion_r463557465



##########
File path: apisix/core/request.lua
##########
@@ -94,7 +94,34 @@ function _M.get_remote_client_port(ctx)
         ctx = ngx.ctx.api_ctx
     end
     return tonumber(ctx.var.remote_port)
-  end
+end
+
+function _M.get_scheme(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return ctx.var.scheme or ''
+end
+
+function _M.get_host(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return ctx.var.host or ''
+end
+
+function _M.get_port(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return tonumber(ctx.var.server_port)
+end
+
+function _M.get_http_version()

Review comment:
       > Keep the style consistent,user acceptance is easier.
   
   We always need APISIX core to have good performance, that is very important.




----------------------------------------------------------------
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] [incubator-apisix] taotao2014 commented on pull request #1953: add core.request.get_scheme/host/port/http_version

Posted by GitBox <gi...@apache.org>.
taotao2014 commented on pull request #1953:
URL: https://github.com/apache/incubator-apisix/pull/1953#issuecomment-667015127


   > @taotao2014 please fix conflicting files: apisix/core/request.lua
   
   Only those with write access to this repository can merge pull requests.


----------------------------------------------------------------
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] [incubator-apisix] taotao2014 commented on a change in pull request #1953: add core.request.get_scheme/host/port/http_version

Posted by GitBox <gi...@apache.org>.
taotao2014 commented on a change in pull request #1953:
URL: https://github.com/apache/incubator-apisix/pull/1953#discussion_r463493811



##########
File path: apisix/core/request.lua
##########
@@ -94,7 +94,34 @@ function _M.get_remote_client_port(ctx)
         ctx = ngx.ctx.api_ctx
     end
     return tonumber(ctx.var.remote_port)
-  end
+end
+
+function _M.get_scheme(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return ctx.var.scheme or ''
+end
+
+function _M.get_host(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return ctx.var.host or ''
+end
+
+function _M.get_port(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return tonumber(ctx.var.server_port)
+end
+
+function _M.get_http_version()

Review comment:
       Keep the style consistent,user acceptance is easier.




----------------------------------------------------------------
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] [incubator-apisix] taotao2014 removed a comment on pull request #1953: add core.request.get_scheme/host/port/http_version

Posted by GitBox <gi...@apache.org>.
taotao2014 removed a comment on pull request #1953:
URL: https://github.com/apache/incubator-apisix/pull/1953#issuecomment-667014825


   > @taotao2014 please fix conflicting files: apisix/core/request.lua
   
   Only those with write access to this repository can merge pull requests.


----------------------------------------------------------------
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] [incubator-apisix] membphis commented on a change in pull request #1953: add core.request.get_scheme/host/port/http_version

Posted by GitBox <gi...@apache.org>.
membphis commented on a change in pull request #1953:
URL: https://github.com/apache/incubator-apisix/pull/1953#discussion_r463446572



##########
File path: apisix/core/request.lua
##########
@@ -94,7 +94,34 @@ function _M.get_remote_client_port(ctx)
         ctx = ngx.ctx.api_ctx
     end
     return tonumber(ctx.var.remote_port)
-  end
+end
+
+function _M.get_scheme(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return ctx.var.scheme or ''
+end
+
+function _M.get_host(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return ctx.var.host or ''
+end
+
+function _M.get_port(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return tonumber(ctx.var.server_port)
+end
+
+function _M.get_http_version()

Review comment:
       How about `_M.get_http_version = ngx.req.http_version` ?




----------------------------------------------------------------
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] [incubator-apisix] taotao2014 commented on a change in pull request #1953: add core.request.get_scheme/host/port/http_version

Posted by GitBox <gi...@apache.org>.
taotao2014 commented on a change in pull request #1953:
URL: https://github.com/apache/incubator-apisix/pull/1953#discussion_r463488169



##########
File path: apisix/core/request.lua
##########
@@ -94,7 +94,34 @@ function _M.get_remote_client_port(ctx)
         ctx = ngx.ctx.api_ctx
     end
     return tonumber(ctx.var.remote_port)
-  end
+end
+
+function _M.get_scheme(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return ctx.var.scheme or ''
+end
+
+function _M.get_host(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return ctx.var.host or ''
+end
+
+function _M.get_port(ctx)
+    if not ctx then
+        ctx = ngx.ctx.api_ctx
+    end
+    return tonumber(ctx.var.server_port)
+end
+
+function _M.get_http_version()

Review comment:
       Method is better




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