HttpSettings Class

Summary

Http Settings to apply to the request
Assembly
Cake.Http.dll
Namespace
Cake.Http
Base Types
  • Object
graph BT Type-->Base0["Object"] Type["HttpSettings"] class Type type-node

Syntax

public class HttpSettings

Constructors

Name Summary
HttpSettings() Http Settings to apply to the request

Properties

Name Value Summary
ClientCertificates IList<X509Certificate2>
List of Client Certificates to be enclosed with the http request.
Cookies IDictionary<string, string>
Collection of 'Cookie(s)' to append to the http request.
EnsureSuccessStatusCode bool
Gets or Sets whether to throw an exception if the returned response is not a Successful Status Code
Headers IDictionary<string, string>
Collection of headers to append to the http request
LogRequestResponseOutput bool
Determines whether to log the response/request body to the console.
RequestBody byte[]
Gets or Sets the Body of the Request
ThrowExceptionOnNonSuccessStatusCode bool
Gets or Sets where an exception is thrown on non success code. This is used in conjunction with EnsureSuccessStatusCode.
Timeout Nullable<TimeSpan>
Time out for http request, default is 100 seconds reference https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.timeout?view=netcore-3.1
UseDefaultCredentials bool
Gets or sets a value that controls whether default credentials are sent with requests by the handler

Extension Methods

Name Value Summary
AppendCookie(string, string) HttpSettings
Appends the cookie to the settings cookie collection
Requires the Cake.Http addin
AppendHeader(string, string) HttpSettings
Appends the header to the settings header collection
Requires the Cake.Http addin
Dump<HttpSettings>() string
Get a basic string representation of specified object.
Requires the Cake.Incubator addin
EnsureSuccessStatusCode(bool) HttpSettings
Sets the EnsureSuccessStatusCode to true. This makes the httpclient throw an error if it does not return a 200 range status.
Requires the Cake.Http addin
IsIn<HttpSettings>(HttpSettings[]) bool
Checks if the source is contained in a list
Requires the Cake.Incubator addin
NotNull<HttpSettings>(string) void
Throws an exception if the specified parameter's value is null.
Requires the Cake.Ftp addin
NotNull<HttpSettings>(string) void
Throws an exception if the specified parameter's value is null.
Requires the Cake.Issues addin
SetAccept(string) HttpSettings
Sets the accept header of the request.
Requires the Cake.Http addin
SetAcceptLanguage(string) HttpSettings
Sets the "Accept-Language" header of the request.
Requires the Cake.Http addin
SetAuthorization(string, string) HttpSettings
Adds a Authorization Header to the request.
Requires the Cake.Http addin
SetContentType(string) HttpSettings
Sets the content-type of the request
Requires the Cake.Http addin
SetFormUrlEncodedRequestBody(IDictionary<string, string>) HttpSettings
Sets the request body as form url encoded. Only valid for Http Methods that allow a request body. Any existing content in the RequestBody is overridden.
Requires the Cake.Http addin
SetFormUrlEncodedRequestBody(IEnumerable<KeyValuePair<string, string>>) HttpSettings
Sets the request body as form url encoded. Only valid for Http Methods that allow a request body. Any existing content in the RequestBody is overridden. Accepts multiple parameters with the same key.
Requires the Cake.Http addin
SetJsonRequestBody<T>(T, bool) HttpSettings
Sets the request body from an object. Serialized as JSON
Requires the Cake.Http addin
SetMultipartFormDataRequestBody(IEnumerable<KeyValuePair<string, string>>, IEnumerable<FilePath>) HttpSettings
Sets the request body as form url encoded. Only valid for Http Methods that allow a request body. Any existing content in the RequestBody is overridden. Accepts multiple parameters with the same key. This can be used to post files to a remote URL
Requires the Cake.Http addin
SetMultipartFormDataRequestBody(IEnumerable<KeyValuePair<string, string>>, IEnumerable<KeyValuePair<string, FilePath>>) HttpSettings
Sets the request body as form url encoded. Only valid for Http Methods that allow a request body. Any existing content in the RequestBody is overridden. Accepts multiple parameters with the same key. This can be used to post files to a remote URL
Requires the Cake.Http addin
SetNoCache() HttpSettings
Appends a Cache-Control header with no-store
Requires the Cake.Http addin
SetOrigin(string) HttpSettings
Sets the origin header to initiate a request for cross-origin resource sharing (asks server for an 'Access-Control-Allow-Origin' response field).
Requires the Cake.Http addin
SetReferer(string) HttpSettings
Sets the "Referer" header of the address of the previous web page from which a link to the currently requested page was followed.
Requires the Cake.Http addin
SetRequestBody(string) HttpSettings
Sets the request body from a string input
Requires the Cake.Http addin
SetTimeout(TimeSpan) HttpSettings
Sets the timeout for the http request
Requires the Cake.Http addin
SuppressLogResponseRequestBodyOutput() HttpSettings
Supresses logging to the console
Requires the Cake.Http addin
ThrowIfNull<HttpSettings>(string, string) T
Throws a System.ArgumentNullException with a specific message if the value is null, otherwise returns the value
Requires the Cake.Incubator addin
ThrowIfNull<HttpSettings>(string) T
Throws a System.ArgumentNullException if the value is null, otherwise returns the value
Requires the Cake.Incubator addin
ToDictionary() IDictionary<string, object>
Requires the Cake.DeployParams addin
UseBasicAuthorization(string, string) HttpSettings
Adds a "Basic" Authorization Header to the request.
Requires the Cake.Http addin
UseBearerAuthorization(string) HttpSettings
Adds a "Bearer" Token Authorization Header to the request. Used when authorization against a resource that uses OAUTH2
Requires the Cake.Http addin
UseClientCertificates(IEnumerable<X509Certificate2>) HttpSettings
Adds client certificate(s) to the http handler.
Requires the Cake.Http addin
UseClientCertificates(X509Certificate2[]) HttpSettings
Adds client certificate(s) to the http handler.
Requires the Cake.Http addin