How to let curl follow a redirct while keeping resolve option?

  Kiến thức lập trình

When curl receives a 302, it starts a dns lookup on test1.com(not exist).

(py37) ❯ curl -L -v http://test1.com/path/1234567 --resolve "test1.com:80:42.186.126.100"
* Added test1.com:80:42.186.126.100 to DNS cache
* Hostname test1.com was found in DNS cache
*   Trying 42.186.126.100:80...
* Connected to test1.com (42.186.126.100) port 80 (#0)
> GET /path/1234567 HTTP/1.1
> Host: test1.com
> User-Agent: curl/7.74.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Moved Temporarily
< Server: nginx
< Date: Mon, 15 Jan 2024 08:01:28 GMT
< Content-Type: text/html
< Content-Length: 154
< Connection: keep-alive
< Location: https://test1.com//path/1234567?
< 
* Ignoring the response-body
* Connection #0 to host test1.com left intact
* Clear auth, redirects to port from 80 to 443Issue another request to this URL: 'https://test1.com//path/1234567'
* Could not resolve host: test1.com
* Closing connection 1
curl: (6) Could not resolve host: test1.com

My expectation is curl will be redirected to https:42.186.126.100:443/path/1234567

LEAVE A COMMENT