Menu

1 / 2

What happens to a POST body after a redirect?

DEV Community: python·UULab·1 day ago
#o9TnUlsP
#devtopython#devto#dev#curl#self
Long article (1188 words) — no AI summary yet.
Reading 0:00
15s threshold

The question: if a URL moves, does the new endpoint receive the same method and body?

Redirecting to a receipt page and moving an order API can look like the same operation. One should show a result without placing another order. The other needs to forward the original order to its new home. Get that distinction wrong and a client may see a final 200 even though the destination got none of the original data.

We sent the same nine bytes and checked what reached the final server. curl sent a bodyless GET after 302 and 303. It kept the POST and body after 307 and 308. In the same experiment, this version of Python's urllib did not follow either 307 or 308.

01. Measure what the destination receives, not just the final response

A Python standard-library server listens on loopback at 127.0.0.1 . Send item=book as POST data to a route named after the status code. The server responds with 302, 303, 307 or 308 and Location: /echo . The destination echoes the method, body length and content that actually arrived.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.