curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: An API for extracing (HTTP) headers?

From: Daniel Stenberg via curl-library <curl-library_at_lists.haxx.se>
Date: Tue, 22 Mar 2022 12:00:43 +0100 (CET)

On Tue, 22 Mar 2022, Timothe Litt via curl-library wrote:

> * Both man pages  : the header "extract a part from a URL" looks like
> an template copy error
> * curl_easy_nextheader: availbleis a typo - available. There are some
> minor language issues that can wait for a later review.

Thanks, these issues should be fixed now.

> curl_easy_header: did you consider returning an array of structures, rather
> than just one?

I did. I decided that it wouldn't improve the API but would make memory
management somewhat more complicated. This way, we don't have to generate any
arrays or lists, making the returned data easier to understand and document.

> This eliminates the BADINDEX error and amount/index in the structure(s), and
> allows the application to make just one call instead of one/instance.  This
> seems simpler and more efficient for the application.

I honestly don't think it makes much difference to applications as you would
need to iterate over entries anyway and then it doesn't matter too much if you
have to call libcurl again or if you can check an already extracted struct.

As I also implemented support extracting headers into the command line tool, I
got a small change to actually work with the API a bit and I found it rather
friendly and straight-forward. It felt good.

> Since the library is holding all the headers, it should not increase the
> amount of memory required.

Yes it would since libcurl does not store the headers internally using the
public struct.

-- 
  / daniel.haxx.se
  | Commercial curl support up to 24x7 is available!
  | Private help, bug fixes, support, ports, new features
  | https://curl.se/support.html


-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2022-03-22