Is it possible to modify or add custom http headers on a 301, 302, 303 or 307 redirect?

浪尽此生 提交于 2019-12-24 10:08:41

问题


Does the HTTP protocol allow a 302 request header to be modified so some parameters can be set and passed to the url receiving the request?


回答1:


302 is a response code, not a request header. The client will resolve the redirect by doing a new request for the new URL, so your client may add whatever headers it want to that new request.

A server wanting some data be sent along to the new URL should do so by appending it to the URL as querystring variables, for example: http://example.com/new-url?variable=data.

If the redirect is happening within your own domain you may also set a cookie which the client may send to the new address. Cookies will only be sent inside the same domain, not if you are redirecting to somewhere else.



来源:https://stackoverflow.com/questions/12883385/is-it-possible-to-modify-or-add-custom-http-headers-on-a-301-302-303-or-307-re

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!