How HTTP redirects handle POST bodies: curl and Python urllib behave differently

A test examined whether a POST body survives an HTTP redirect when a URL has moved. A local server returned 302, 303, 307 or 308 pointing to a destination that reported what it received. curl switched to a bodyless GET after 302 and 303, but kept the POST and body after 307 and 308. Python's default urllib did not follow either 307 or 308, raising an exception instead. The author notes that a status change tested only with curl could strand other clients at the old endpoint. The advice is to pick redirect codes deliberately, keep old routes available where clients cannot be controlled, and verify arrivals at the destination rather than relying on the final status code.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in