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: CURLOPT_HEADERFUNCTION and buffer modifications

From: Clťment Gregoire via curl-library <curl-library_at_cool.haxx.se>
Date: Thu, 3 Oct 2019 12:12:44 +0000

Thanks for the quick answer, I'll fallback to having a copy of the substring then !

Clément Gregoire | Engine Programmer

ASOBO Studio
23 Parvis des Chartrons, 33074 Bordeaux Cedex France
P +33 5 56 01 04 98 | M cgregoire_at_asobostudio.com | W www.asobostudio.com | f / t @AsoboStudio

L'intégrité de ce message n'étant pas assurée sur internet, ASOBO STUDIO ne peut être tenue responsable de son contenu. Toute utilisation ou diffusion non autorisée est interdite. Si vous n'êtes pas destinataire de ce message, merci de le détruire et d'avertir l'expéditeur. Les opinions, conclusions, idées exprimées dans ce message, qui seraient sans relation avec l'activité d'ASOBO STUDIO, ne peuvent être considérées ni comme émises ni comme approuvées par ASOBO STUDIO. The integrity of this message cannot be guaranteed on the Internet. ASOBO STUDIO cannot therefore be considered responsible for the contents. Any unauthorized use or dissemination is prohibited. If you are not the intended recipient of this message, then please delete it and notify the sender. Opinions, conclusions, or other statements in this message which do not relate to the business of ASOBO STUDIO are neither given nor endorsed by ASOBO STUDIO.

        Avant d'imprimer, pensez √† l'environnement - Think about environment before printing

-----Message d'origine-----
De : Daniel Stenberg [mailto:daniel_at_haxx.se]
Envoyé : jeudi 3 octobre 2019 11:56
À : Clément Gregoire via curl-library <curl-library_at_cool.haxx.se>
Cc : Clément Gregoire <CGregoire_at_asobostudio.com>
Objet : Re: CURLOPT_HEADERFUNCTION and buffer modifications

On Thu, 3 Oct 2019, Clément Gregoire via curl-library wrote:

> I'm using CURLOPT_HEADERFUNCTION to read/parse headers, and it'd be
> useful for me if I could replace some characters with for example the
> '\0'. Typical usage would be for strtok. Is this allowed ? I know the
> header callback buffer member is `char*` and not `const char*` but I
> still wanted to make sure.

A fair question as it isn't specifically mentioned in the documentation. We should probably add something to this effect.

I would strongly discourage doing that. The prototype and callbacks should be considered a 'const char *'. Not using that was just an omission (by me) and stuck like this to not rock the boat.

You will *likely* be able to write to that buffer without it hurting, but that's not something we can guarantee will continue to work nor that it worked correctly in older libcurl versions.

That's also why strtok_r() and friends were invented! ;-)

-- 
  / daniel.haxx.se | Get the best commercial curl support there is - from me
                   | Private help, bug fixes, support, ports, new features
                   | https://www.wolfssl.com/contact/
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2019-10-03