| Implement HTTP redirection based on puppet's current behavior:
- If the HTTP response code is 301, 302, 307, then follow the redirect using the Location response header.
- Codes 300, 303, 304, 305, and 308 are treated as errors
- Follow redirects for all HTTP methods, even unsafe ones like PUT
- Always preserve the HTTP method, for example, never switch from POST to GET
- Preserve all headers, except Host.
- Preserve all query parameters
- Raise an exception if we redirect more than the limit, which defaults to 10
- Redirection loops are handled by the redirect limit
Additionally responses 301, 302, and 307 may have a response body. The response body must be fully read/drained when using persistent connections, otherwise, the next request will read the body from the redirected request. |