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
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.
HttpAddRequestHeaders function
HTTP_ADDREQ_FLAG_ADD
Adds the header if it does not exist. Used with HTTP_ADDREQ_FLAG_REPLACE.
HTTP_ADDREQ_FLAG_ADD_IF_NEW
Adds the header only if it does not already exist; otherwise, an error is returned.
HTTP_ADDREQ_FLAG_COALESCE
Coalesces headers of the same name.
HTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA
Coalesces headers of the same name. For example, adding "Accept: text/" followed by "Accept: audio/" with this flag results in the formation of the single header "Accept: text/, audio/". This causes the first header found to be coalesced. It is up to the calling application to ensure a cohesive scheme with respect to coalesced/separate headers.
HTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON
Coalesces headers of the same name using a semicolon.
HTTP_ADDREQ_FLAG_REPLACE
Replaces or removes a header. If the header value is empty and the header is found, it is removed. If not empty, the header value is replaced.
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.