cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: multiple HTTP requests/responses when using proxy authentication

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 9 Aug 2013 23:10:16 +0200 (CEST)

On Fri, 9 Aug 2013, Václav Zeman wrote:

> We are using libcurl as a transport backend for gSOAP because libcurl
> has better proxy authentication capabilities.
>
> When I send a HTTP request through proxy with authentication, my
> CURLOPT_WRITEFUNCTION callback is receiving all headers, even headers from
> proxy authentication negotiation.

Ah yes, the headers. The headers from all responses will come flying down the
callback indeed. But then you'll always get a CRLF ending the server response
headers so you at least know when one set ends.

> My CURLOPT_WRITEFUNCTION callback is basically gathering all the data it
> receives and gSOAP then reads the whole response at once.

The writefunction doesn't get the headers unless you explicitly ask for them
to go there though... Wouldn't it then be easier to have a separate header
callback and just clear the response headers you have stored in case you get
more after a previous CRLF?

> But the documentation states that the HTTP/1.1 chunked response can contain
> the trailer that is the same as the status line.

It does? Are you sure? It was a while since I read the trailer docs but I
believe it says they are sent has ordinary headers ie not like the status
line.

(We've had some patches flying that would add proper trailer support in
libcurl but they were never completed and thus not merged.)

> While I can probably insert enough logic into the code to distinguish the
> trailer from the status line (as per the clues in CURLOPT_HEADERFUNCTION
> docs), I would rather have libcurl letting me know when it is starting a new
> HTTP request.

Trailer headers are certainly a bit tricky and will indeed mess up the easy
scheme I mention above. I tend to forget them since they're just so unusual.

Perhaps you could detect the trailer headers by the fact that you've received
a response body by the time they appear and no other headers should otherwise
come after the "payload" ?

-- 
  / daniel.haxx.se

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