Customizing POST headers

By itself, the XHTTPF_REQPOST flag will generate a standard set of headers to accompany the specified request, e.g.:

POST /my/web/service HTTP/1.1

Host: mydomain.com

Content-Type: text/plain; charset="ansi"

Content-Length: 84

 

<body of request here>

 

But let's suppose you don't like the auto-generated Content-Type, and want to add your own Authorization line. You can do this by modifying your request file (we're assuming XHTTPF_FILEREQ) to add the desired headers at top, separated from your request body by a blank line, and then add the XHTTPF_HDRBODY flag. (Note: this is a slightly different situation than the previous example using XHTTPF_REQUPLOAD; in that case the Content-Type and name header for the individually uploaded files could be addressed via special syntax in the request parameter. In this case we are changing the main header for the entire request.) For example:

Content-Type: application/json; charset=utf-8

Authorization: Basic YWdlYmFwaTpCN2VyQDhhYw==

 

<body of request here>

 

Submitting the above file, using XHTTPF_REQPOST + XHTTPF_HDRBODY + XHTTPF_FILEREQ would result in the auto-generated Content-Type line being changed to the one specified in our request file, and the Authorization line we specified being added, as follows:

POST /my/web/service HTTP/1.1

Host: mydomain.com

Content-Type: application/json; charset="utf-8"

Authorization: Basic YWdlYmFwaTpCN2VyQDhhYw==

Content-Length: 84

 

<body of request here>