cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: fallback from HTTP 1.1 to HTTP 1.0 for multiple curl sessions

From: Girish Aher <girishaher_at_gmail.com>
Date: Wed, 6 Aug 2014 16:29:46 +0530

Hi Dan,
Thanks for the elaborate explanation. The essence of my question was in
fact related to the use of "Expect" header in requests. I found libcurl
sending Expect headers (and with HTTP 1.1) even though previous requests
(same or different sessions) to the same server identify it to be a HTTP
1.0 endpoint.
I generalized it to a distinction between HTTP 1.1 and 1.0.

When I searched a bit more, I figured out that it is known issue with
libcurl as mentioned here.
http://curl.haxx.se/docs/knownbugs.html (#61)

As part of the fallback to HTTP 1.0, I expected libcurl to send another
request with Expect header removed, but libcurl unfortunately does not do
this right now as per the known issue.
So I will need to do the suggested workaround in my code - in case I see a
417 response, I need to send another identical request but with Expect
header removed.

Your response that the server HTTP version is maintained inside a
connection structure helps in understanding. The problem is that once I
receive a 417 from server, the underlying TCP connection is also closed
(due to HTTP "Connection: close" header in response). A new connection is
created for same request for a reattempt but this new connection does not
still know the server HTTP version. So it receives 417 again and thus the
request is never successful even after infinite attempts.

You may treat this query as resolved for now since there is the known issue
already logged.

Thanks again.

--G

On Wed, Aug 6, 2014 at 2:32 PM, Dan Fandrich <dan_at_coneharvesters.com> wrote:

> On Wed, Aug 06, 2014 at 12:40:54AM +0530, Girish Aher wrote:
> > I am using libcurl in a multi-threaded program wherein each thread has
> its own
> > curl session handle as per the documentation. All the sessions talk to
> the same
> > destination web server to upload data over http and they pass through a
> **HTTP
> > 1.0** proxy.
> >
> > My question here - I understand (and I hope to be right here) that a curl
> > connection ascertains from the proxy response that it needs to fallback
> (from
> > the default 1.1) to HTTP 1.0 for further communication on same session
> handle.
> > So, does libcurl maintain some kind of global cache that all the the
> other
> > session handles in the other threads (or connections within the same
> handle)
> > may use and know to start with HTTP 1.0 instead of the default HTTP 1.1?
>
> The HTTP version number of the server is maintained as a part of the
> connection data structure. libcurl keeps a number of connections open at
> once
> in a connection pool, so a connection can be used by a number of different
> requests over time. Once the server version is known, all requests on that
> connection will conform to the version in use unless overridden by the
> application.
>
> > I cannot do a setopt to force HTTP 1.0 for every session handle since my
> > program may use various proxies over time. What would be the best
> approach
> > here?
> >
> > Appreciate any guidance here.
>
> I'm not sure what exactly you're asking here. libcurl takes care of the
> HTTP
> 1.0 vs 1.1 distinction internally, so why does your application care about
> the
> HTTP version in use on the server?
>
> >>> Dan
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-08-06