How to forward headers on HTTP redirect

2019-01-07 22:13发布

I'm writing a webapp that reponses an HTTP redirect. Is there a way to force the client to forward the headers I include in the response to the new url?

Example request:

POST /insertion HTTP/1.1
Content-Length: 9

(content)

Webapp response:

HTTP/1.x 302 Found
Location: /dock
Mydata: asdf

Next client request:

GET /dock HTTP/1.1
Mydata: asdf

Update: It seems I wasn't clear on the matter. I know cookies would be useful, but I can't use them. Do you know whether exists something like what i'm searching for?

3条回答
爷的心禁止访问
2楼-- · 2019-01-07 22:31

Put your data in the new url as an argument:

HTTP/1.x 302 Found
Location: /dock?data=asdf

or save it in cookies

HTTP/1.x 302 Found
Location: /dock
Set-Cookie: data=asdf
查看更多
爷、活的狠高调
3楼-- · 2019-01-07 22:36

This is what cookies are used for. You can set it for the browser session and invalidate it after the next request.

查看更多
Lonely孤独者°
4楼-- · 2019-01-07 22:54

Other than HTTP cookies, there's nothing in the protocol specification about forwarding headers. The client needs to implement this functionality.

查看更多
登录 后发表回答