Discussion:
Behaviour with CURLOPT_FRESH_CONNECT when libcurl performs a request internally
John Smith via curl-library
2018-11-29 18:11:08 UTC
Permalink
Hello,

curl version: v7_57_0

I'm working on a piece of software which works in two modes:
- normal mode where we are re-using existing connections
- degraded mode where CURLOPT_FRESH_CONNECT is enabled on every HTTP
request

The degraded mode is activated after a transfer fails due to a stale
connection (I've noticed this can happen because e.g. the server terminated
a connection but for some reason we didn't receive the FIN packet).

I'm having an issue in this mode when the server responds with "HTTP/1.1
401 Unauthorized" to a GET request I just performed. In that case, libcurl
is internally performing an HTTP request to send the authorization; and
that request is made using an already existing connection somehow ignoring
the FRESH_CONNECT option I passed to the original request.

Is there a way I could force libcurl to open a new connection also when it
performs a request internally (generally or at least when handling 401)?

Thanks,
John
Daniel Stenberg via curl-library
2018-12-03 09:38:55 UTC
Permalink
Post by John Smith via curl-library
- degraded mode where CURLOPT_FRESH_CONNECT is enabled on every HTTP
request
I'm having an issue in this mode when the server responds with "HTTP/1.1 401
Unauthorized" to a GET request I just performed. In that case, libcurl is
internally performing an HTTP request to send the authorization; and that
request is made using an already existing connection somehow ignoring the
FRESH_CONNECT option I passed to the original request.
Is there a way I could force libcurl to open a new connection also when it
performs a request internally (generally or at least when handling 401)?
Thanks for this report!

Presumably you're also using NTLM or Negotiate authentication too where
disconnecting is really breaking things?

But no, we don't have any external way to change this behavior. I would rather
consider this a bug that we should handle ourselves without the application
having to do anything at all about it. There's code in libcurl that attempts
to act "correctly" when then apparently isn't enough?

https://github.com/curl/curl/blob/847b13024417ea42b0123fcdb33ce53bf12619f7/lib/url.c#L3878

Can you figure out why?

Do you have any public URL we can reproduce this on?

Also, please post this as an issue on github
(https://github.com/curl/curl/issues) so that we don't forget about it!
--
/ daniel.haxx.se
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Eti
Loading...