HttpHandler

class EosSharp::HttpHandler
  : public IHttpHandler

Http Handler implementation using System.Net.Http.HttpClient.

Summary

MembersDescriptions

private Dictionary< string, object > ResponseCache

public void ClearResponseCache()

Clear cached responses from requests called with Post/GetWithCacheAsync.

public async Task< TResponseData > PostJsonAsync< TResponseData >(string url, object data)

Make post request with data converted to json asynchronously.

public async Task< TResponseData > PostJsonAsync< TResponseData >(string url, object data, CancellationToken cancellationToken)

Make post request with data converted to json asynchronously.

public async Task< TResponseData > PostJsonWithCacheAsync< TResponseData >(string url, object data, bool reload)

Make post request with data converted to json asynchronously. Response is cached based on input (url, data)

public async Task< TResponseData > PostJsonWithCacheAsync< TResponseData >(string url, object data, CancellationToken cancellationToken, bool reload)

Make post request with data converted to json asynchronously. Response is cached based on input (url, data)

public async Task< TResponseData > GetJsonAsync< TResponseData >(string url)

Make get request asynchronously.

public async Task< TResponseData > GetJsonAsync< TResponseData >(string url, CancellationToken cancellationToken)

Make get request asynchronously.

public async Task< Stream > SendAsync(HttpRequestMessage request)

Generic http request sent asynchronously.

public async Task< Stream > SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)

Generic http request sent asynchronously.

public void UpdateResponseDataCache< TResponseData >(string hashKey, TResponseData responseData)

Upsert response data in the data store.

public string GetRequestHashKey(string url, object data)

Calculate request unique hash key.

public async Task< Stream > BuildSendResponse(HttpResponseMessage response)

Convert response to stream.

public async Task< string > StreamToStringAsync(Stream stream)

Convert stream to a string.

public TData DeserializeJsonFromStream< TData >(Stream stream)

Generic method to convert a stream with json data to any type.

public HttpRequestMessage BuildJsonRequestMessage(string url, object data)

Build json request data from object data.

Members

private Dictionary< string, object > ResponseCache

public void ClearResponseCache()

Clear cached responses from requests called with Post/GetWithCacheAsync.

public async Task< TResponseData > PostJsonAsync< TResponseData >(string url, object data)

Make post request with data converted to json asynchronously.

Parameters

  • TResponseData Response type

Parameters

  • url Url to send the request

  • data data sent in the body

Returns

Response data deserialized to type TResponseData

public async Task< TResponseData > PostJsonAsync< TResponseData >(string url, object data, CancellationToken cancellationToken)

Make post request with data converted to json asynchronously.

Parameters

  • TResponseData Response type

Parameters

  • url Url to send the request

  • data data sent in the body

  • cancellationToken Notification that operation should be canceled

Returns

Response data deserialized to type TResponseData

public async Task< TResponseData > PostJsonWithCacheAsync< TResponseData >(string url, object data, bool reload)

Make post request with data converted to json asynchronously. Response is cached based on input (url, data)

Parameters

  • TResponseData Response type

Parameters

  • url Url to send the request

  • data data sent in the body

  • reload ignore cached value and make a request caching the result

Returns

Response data deserialized to type TResponseData

public async Task< TResponseData > PostJsonWithCacheAsync< TResponseData >(string url, object data, CancellationToken cancellationToken, bool reload)

Make post request with data converted to json asynchronously. Response is cached based on input (url, data)

Parameters

  • TResponseData Response type

Parameters

  • url Url to send the request

  • data data sent in the body

  • cancellationToken Notification that operation should be canceled

  • reload ignore cached value and make a request caching the result

Returns

Response data deserialized to type TResponseData

public async Task< TResponseData > GetJsonAsync< TResponseData >(string url)

Make get request asynchronously.

Parameters

  • TResponseData Response type

Parameters

  • url Url to send the request

Returns

Response data deserialized to type TResponseData

public async Task< TResponseData > GetJsonAsync< TResponseData >(string url, CancellationToken cancellationToken)

Make get request asynchronously.

Parameters

  • TResponseData Response type

Parameters

  • url Url to send the request

  • cancellationToken Notification that operation should be canceled

Returns

Response data deserialized to type TResponseData

public async Task< Stream > SendAsync(HttpRequestMessage request)

Generic http request sent asynchronously.

Parameters

  • request request body

Returns

Stream with response

public async Task< Stream > SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)

Generic http request sent asynchronously.

Parameters

  • request request body

///

Parameters

  • cancellationToken Notification that operation should be canceled

Returns

Stream with response

public void UpdateResponseDataCache< TResponseData >(string hashKey, TResponseData responseData)

Upsert response data in the data store.

Parameters

  • TResponseData response data type

Parameters

  • hashKey data key

  • responseData response data

public string GetRequestHashKey(string url, object data)

Calculate request unique hash key.

Parameters

  • url Url to send the request

  • data data sent in the body

Returns

public async Task< Stream > BuildSendResponse(HttpResponseMessage response)

Convert response to stream.

Parameters

  • response response object

Returns

Stream with response

public async Task< string > StreamToStringAsync(Stream stream)

Convert stream to a string.

Parameters

  • stream

Returns

public TData DeserializeJsonFromStream< TData >(Stream stream)

Generic method to convert a stream with json data to any type.

Parameters

  • TData type to convert

Parameters

  • stream stream with json content

Returns

TData object

public HttpRequestMessage BuildJsonRequestMessage(string url, object data)

Build json request data from object data.

Parameters

  • url Url to send the request

  • data object data

Returns

request message

Last updated