HttpClient.HttpClient(IHttpFilter) constructor

Applies to Windows and Windows Phone

Initializes a new instance of the HttpClient class with a specific filter for handling HTTP response messages.

Syntax


Public Sub New (
  filter As IHttpFilter 
)

Parameters

filter

Type: IHttpFilter

The HTTP filter to use for handling response messages.

Remarks

If a null reference (Nothing in Visual Basic) is specified for the filter parameter, the default transport handler for receiving responses with no filter is used.

Examples

The sample code shows creating an HttpClient to use a custom filter.



internal static void CreateHttpClient(ref HttpClient httpClient)
{
    if (httpClient != null) {
        httpClient.Dispose();
    }

    // HttpClient can be extended by plugging multiple filters together,
    // providing HttpClient with the configured filter pipeline.
    var baseFilter = new HttpBaseProtocolFilter();

    var myFilter = new MyCustomFilter(baseFilter);
    httpClient = new HttpClient(myFilter);
}



Requirements

Minimum supported client

Windows 8.1

Minimum supported server

Windows Server 2012 R2

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.Web.Http
Windows::Web::Http [C++]

Metadata

Windows.winmd

See also

HttpClient
HttpClient constructor
IHttpFilter
Windows.Web.Http.Filters

 

 

Show:
© 2014 Microsoft