c++wininet

What is the difference between the headers added by HttpAddRequestHeaders and the ones sent by HttpSendRequest


I'm dealing with WinInet and I want to know what is the practical difference between the headers that are set by the HttpAddRequestHeaders function (using a HttpOpenRequest handle) and that ones that are sent by the HttpSendRequest function.

To simplify my code there are one better place to define such headers? I would want to avoid deal with these two ways


Solution

  • Per the Microsoft documentation:

    The function also lets the client specify optional data to send to the HTTP server immediately following the request headers. This feature is generally used for "write" operations such as PUT and POST.

    So if all you want to do is "add request headers", either API will give you the same functionality.

    If you want to do "something special" (like "coalesce headers") you might to choose one or the other API.