Skip to content

Options

vixez edited this page Apr 18, 2016 · 3 revisions

Options

Setting options

You can pass on options to the GET/POST/PUT/DELETE function. For example:

JsonHttp.Options options = new JsonHttp.Options()
{
    AllowAutoRedirect = true,
    DefaultRequestHeaders = new Dictionary<string, string>(),
    AddMediaTypeWithQualityHeadersJson = true,
    UseLocationHeaderForRedirects = true
};

Then you can add the options at the end:

WordOfTheDay wotd = await JsonHttp.Get<WordOfTheDay>(new Uri("http://urban-word-of-the-day.herokuapp.com/today"), options);

AllowAutoRedirect

This allows to follow redirect responses

UseLocationHeaderForRedirects

When a redirect response is received, the Location header in the response will be used as redirect URL

AddMediaTypeWithQualityHeadersJson

Adds an accept header of "application/json"

DefaultRequestHeaders

You can add a dictionary of headers to add to DefaultRequestHeaders

Timeout

Sets a timeout on the request, an exception is thrown when a timeout occurs

HttpClient

Override the HttpClient used in the library, this also overrides all of the set options

Clone this wiki locally