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 2021/05/19 04:42:04 UTC

[GitHub] [apisix] silveric10 opened a new issue #4271: request help: The request header added by A plugin can't be used for B plugin

silveric10 opened a new issue #4271:
URL: https://github.com/apache/apisix/issues/4271


   ### Issue description
   I have to plugins, A and B, plugin A's function is adding a request header, then plugin B can get this header to do other things. But I found that when my code is like this behind: 
   funciton _M.rewrite()
       ... ... 
       ngx.req.set_header("header-added-by-plugin-A",  "test_content")
       ngx.log(ngx.DEBUG, core.request.header(ctx, "header-added-by-plugin-A"))
   end
   
   The header's value in log file is nil, and plugin B also can't get this header's value. But on the real server, I can get this header. How can I add a request header in plugin A and make it useable for plugin B? Thank you
   ### Environment
   
   Request help without environment information will be ignored or closed.
   
   * apisix version (cmd: `apisix version`):
   * OS (cmd: `uname -a`):
   * OpenResty / Nginx version (cmd: `nginx -V` or `openresty -V`):
   * etcd version, if have (cmd: run `curl http://127.0.0.1:9090/v1/server_info` to get the info from server-info API):
   * apisix-dashboard version, if have:
   * luarocks version, if the issue is about installation (cmd: `luarocks --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] [apisix] silveric10 commented on issue #4271: request help: The request header added by A plugin can't be used for B plugin

Posted by GitBox <gi...@apache.org>.
silveric10 commented on issue #4271:
URL: https://github.com/apache/apisix/issues/4271#issuecomment-843799957


   Maybe you can add a flag that we can choose to force update the headers or just use the cached data


-- 
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] spacewander commented on issue #4271: request help: The request header added by A plugin can't be used for B plugin

Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #4271:
URL: https://github.com/apache/apisix/issues/4271#issuecomment-843853933


   The problem is already fixed in https://github.com/apache/apisix/pull/2917.
   You may need to upgrade your APISIX.


-- 
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] silveric10 commented on issue #4271: request help: The request header added by A plugin can't be used for B plugin

Posted by GitBox <gi...@apache.org>.
silveric10 commented on issue #4271:
URL: https://github.com/apache/apisix/issues/4271#issuecomment-843858377


   Got it, thank you, now close this 


-- 
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] silveric10 closed issue #4271: request help: The request header added by A plugin can't be used for B plugin

Posted by GitBox <gi...@apache.org>.
silveric10 closed issue #4271:
URL: https://github.com/apache/apisix/issues/4271


   


-- 
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] silveric10 commented on issue #4271: request help: The request header added by A plugin can't be used for B plugin

Posted by GitBox <gi...@apache.org>.
silveric10 commented on issue #4271:
URL: https://github.com/apache/apisix/issues/4271#issuecomment-843782889


   I know, seems that "core.request.header" will only be updated once when it first calling.


-- 
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] spacewander commented on issue #4271: request help: The request header added by A plugin can't be used for B plugin

Posted by GitBox <gi...@apache.org>.
spacewander commented on issue #4271:
URL: https://github.com/apache/apisix/issues/4271#issuecomment-843754225


   > Request help without environment information will be ignored or closed.
   
   Please fix the Environment section, otherwise we will close this.


-- 
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] Firstsawyou commented on issue #4271: request help: The request header added by A plugin can't be used for B plugin

Posted by GitBox <gi...@apache.org>.
Firstsawyou commented on issue #4271:
URL: https://github.com/apache/apisix/issues/4271#issuecomment-843785136


   You need to make sure that the execution priority of plugin A that sets the request header is greater than plugin B. How to set the request header, you can parameter proxy-rewrite plugin: https://github.com/apache/apisix/blob/master/apisix/plugins/proxy-rewrite.lua#L197


-- 
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] silveric10 commented on issue #4271: request help: The request header added by A plugin can't be used for B plugin

Posted by GitBox <gi...@apache.org>.
silveric10 commented on issue #4271:
URL: https://github.com/apache/apisix/issues/4271#issuecomment-843770952


   > > Request help without environment information will be ignored or closed.
   > 
   > Please fix the Environment section, otherwise we will close this.
   
   Fixed


-- 
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] silveric10 commented on issue #4271: request help: The request header added by A plugin can't be used for B plugin

Posted by GitBox <gi...@apache.org>.
silveric10 commented on issue #4271:
URL: https://github.com/apache/apisix/issues/4271#issuecomment-843794735


   > You need to make sure that the execution priority of plugin A that sets the request header is greater than plugin B. How to set the request header, you can parameter proxy-rewrite plugin: https://github.com/apache/apisix/blob/master/apisix/plugins/proxy-rewrite.lua#L197
   Thanks.
   I'm sure that plugin A's priority is greater than plugin B's priority. I think the reason is I called core.request.header(ctx, ...) at the begining of plugin A, and set new header before plugin A return. The function core.request.header() only be update when it's first call, I think here is the code:    
   ```
    local headers = ctx.headers
    if not headers then
        headers = get_headers()
        ctx.headers = headers
   end
   ```


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