Is it possible to modify or add custom http header

2019-07-31 23:58发布

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条回答
不美不萌又怎样
2楼-- · 2019-08-01 00:45

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.

查看更多
登录 后发表回答