curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: Point in time during HTTP 3xx response handling with CURLOPT_FOLLOWLOCATION when Location headers are followed

From: Daniel Stenberg via curl-library <curl-library_at_cool.haxx.se>
Date: Sun, 7 Apr 2019 23:51:21 +0200 (CEST)

On Sun, 7 Apr 2019, Nicolas Roeser via curl-library wrote:

> But for now I can not understand the necessity of reading the HTTP response
> body for a 302 response _at all_(*) when there is a usable Location header
> field.

curl doesn't *have to*, but it choses to. Keeping the connection alive and
reading a little extra data over it, is usually much faster than tearing down
the connection and creating a new for next request.

If this is done over HTTP/2 (or the coming HTTP/3), the 302 request should be
aborted since we can do that and still maintain the connection but I'm pretty
sure this optimization is still left to implement.

> Or am I using the wrong means for accomplishing my goal described above? Do
> I need to implement redirection following myself?

That could be a way to force this behavior you want, sure. But depending on
many conditions, that's not necessarily the faster way.

> (*) Having thought about it a little more – is this behavior related to
> keep-alive connections and not wanting to close them/open new ones?

Yes it is exactly that!

-- 
  / daniel.haxx.se

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2019-04-07