wise0wl
wise0wl

Reputation: 11

Possibility of doing a HTTP redirect mid-response?

I have not found a positive answer anywhere, so here goes...

I would like to do a chunked encoding style response and redirect the client mid-stream to another URL.

Something like so:

HTTP/1.1 200 OK
Content-Type: text/plain
Transfer-Encoding: chunked

5
abcde
0
HTTP/1.1 307 See Other
Location: http://localhost:8081/

I have a feeling that this is simply not possible, but I was hoping someone more versed in the HTTP spec than I was would have a definitive answer for me. Thanks in advance!

Upvotes: 1

Views: 70

Answers (1)

deed02392
deed02392

Reputation: 5022

This is absolutely not possible without breaking the HTTP spec.

Your best alternative, if you need to send data and then issue a redirect, might be to use a redirect and custom headers to send the data.

But basically you're asking the wrong question. What do you want to achieve would be a better question to ask, rather than how can you break protocol to try and achieve what you want. :)

Upvotes: 2

Related Questions