ariary/HTTPCustomHouse

Feature: follow code 302

Closed this issue · 0 comments

With an option -L enable use to follow redirect

  • Find Location header (The address itself can be either absolute or relative)
  • Search for Set-Cookie header to perform the redirect request with

by default perform request w/ same cookie

Extra Notes

https://everything.curl.dev/http/redirects

example of response:

HTTP/1.1 302 Found
Location: /admin
Set-Cookie: session=frferfreferqferferfgerfe; Secure; HttpOnly; SameSite=None
Connection: close
Content-Length: 0

How to make Curl follow redirects?
To follow redirect with Curl, use the -L or --location command-line option. This flag tells Curl to resend the request to the new address. When you send a POST request, and the server responds with one of the codes 301, 302, or 303, Curl will make the subsequent request using the GET method. For other 300x status codes, Curl will resend the subsequent request using the same unmodified HTTP method. This behavior can be changed using one of the --post301, --post302, or --post303 flags. When authentication is used, Curl only sends its credentials to the first host. If Curl goes to a different host when redirecting, it will not provide user credentials to the new host (you can change this behavior with the --location-trust flag). To limit the number of following redirects, you can use the --max-redirs command-line option.