BITS HTTPHEADER Sample

Summary

This sample demonstrates using the BITS APIs that allow you to modify HTTP headers. HTTP headers are in the HTTP 1.1 protocol to allow HTTP servers and HTTP clients to communicate their intentions. For example a request header can be passed by a client to a server that gives the server additional information about the request. The HTTP 1.1 specification (http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html) provides some examples of the usage of headers.

Should a client pass a request header like:

Accept: audio/*; q=0.2, audio/basic

This should be interpreted by the server as "I prefer audio/basic, but send me any audio type if it is the best available after an 80% mark-down in quality."

The Accept request-header field can be used to specify certain media types which are acceptable for the response. Accept headers can be used to indicate that the request is specifically limited to a small set of desired types, as in the case of a request for an in-line image.

BITS has the ability to allow API callers to specify their own custom headers that are passed to the HTTP server as part of the HTTP protocol.

Program flow

In this sample, the request property “Accept-Encoding: gzip, deflate” is used. When passed to the server, it tells the server that the client will accept responses compressed in gzip format. HTTPHEADER.cpp builds on the concepts established in the DOWNLOADS.cpp example, it is recommended that you review DOWNLOADS.cpp prior to reviewing this sample – it will aid understanding of the program flow. The key difference between the two samples is the use of the SetCustomHeaders method in the IBackgroundCopyJobHttpOptions interface.

Key Concepts

Build/Configuration instructions

Basic Usage

Notes:

System configuration