ReqRest
Show / Hide Table of Contents

Class HttpContentBuilderExtensions

Defines the static methods for an IHttpContentBuilder provided by the library.

Inheritance
Object
HttpContentBuilderExtensions
Namespace: ReqRest.Builders
Assembly: ReqRest.dll
Syntax
public static class HttpContentBuilderExtensions

Methods

AddContentHeader<T>(T, String)

Adds the specified header without any value to the Headers of the HTTP content which is being built.

Declaration
public static T AddContentHeader<T>(this T builder, string name)
    where T : IHttpContentBuilder
Parameters
Type Name Description
T builder

The builder.

String name

The name of the header.

Returns
Type Description
T

The specified builder.

Type Parameters
Name Description
T

The type of the builder.

Exceptions
Type Condition
ArgumentNullException
  • builder
  • name

AddContentHeader<T>(T, String, Nullable<IEnumerable<Nullable<String>>>)

Adds the specified header and its values to the Headers of the HTTP content which is being built.

Declaration
public static T AddContentHeader<T>(this T builder, string name, IEnumerable<string? >? values)
    where T : IHttpContentBuilder
Parameters
Type Name Description
T builder

The builder.

String name

The name of the header.

Nullable<IEnumerable<Nullable<String>>> values

The content/values of the header. This can be null.

Returns
Type Description
T

The specified builder.

Type Parameters
Name Description
T

The type of the builder.

Exceptions
Type Condition
ArgumentNullException
  • builder
  • name

AddContentHeader<T>(T, String, Nullable<String>)

Adds the specified header and its value to the Headers of the HTTP content which is being built.

Declaration
public static T AddContentHeader<T>(this T builder, string name, string? value)
    where T : IHttpContentBuilder
Parameters
Type Name Description
T builder

The builder.

String name

The name of the header.

Nullable<String> value

The content/value of the header. This can be null.

Returns
Type Description
T

The specified builder.

Type Parameters
Name Description
T

The type of the builder.

Exceptions
Type Condition
ArgumentNullException
  • builder
  • name

ClearContentHeaders<T>(T)

Removes all headers from the Headers of the HTTP content which is being built.

Declaration
public static T ClearContentHeaders<T>(this T builder)
    where T : IHttpContentBuilder
Parameters
Type Name Description
T builder

The builder.

Returns
Type Description
T

The specified builder.

Type Parameters
Name Description
T

The type of the builder.

Exceptions
Type Condition
ArgumentNullException
  • builder

ConfigureContentHeaders<T>(T, Action<HttpContentHeaders>)

Executes the specified configureHeaders function to modify the Headers of the HTTP content which is being built.

Declaration
public static T ConfigureContentHeaders<T>(this T builder, Action<HttpContentHeaders> configureHeaders)
    where T : IHttpContentBuilder
Parameters
Type Name Description
T builder

The builder.

Action<HttpContentHeaders> configureHeaders

A function which receives the Headers object. The function can then modify the headers as desired.

Returns
Type Description
T

The specified builder.

Type Parameters
Name Description
T

The type of the builder.

Exceptions
Type Condition
ArgumentNullException
  • builder
  • configureHeaders

RemoveContentHeader<T>(T, Nullable<String>[], names)

Removes the headers with the specified names from the Headers of the HTTP content which is being built.

Declaration
public static T RemoveContentHeader<T>(this T builder, params string? [], names)
    where T : IHttpContentBuilder
Parameters
Type Name Description
T builder

The builder.

Nullable<String>[]
names
Returns
Type Description
T

The specified builder.

Type Parameters
Name Description
T

The type of the builder.

Exceptions
Type Condition
ArgumentNullException
  • builder

SetContent<T>(T, Byte[])

Sets the HTTP content to a new ByteArrayContent instance which is created from the specified content.

Declaration
public static T SetContent<T>(this T builder, byte[] content)
    where T : IHttpContentBuilder
Parameters
Type Name Description
T builder

The builder.

Byte[] content

The new HTTP content as a byte array.

Returns
Type Description
T

The specified builder.

Type Parameters
Name Description
T

The type of the builder.

Exceptions
Type Condition
ArgumentNullException
  • builder
  • content

SetContent<T>(T, Byte[], Int32, Int32)

Sets the HTTP content to a new ByteArrayContent instance which is created from the specified content.

Declaration
public static T SetContent<T>(this T builder, byte[] content, int offset, int count)
    where T : IHttpContentBuilder
Parameters
Type Name Description
T builder

The builder.

Byte[] content

The new HTTP content as a byte array.

Int32 offset

A zero-based offset in content from which sending starts.

Int32 count

The number of bytes to be sent, starting from offset.

Returns
Type Description
T

The specified builder.

Type Parameters
Name Description
T

The type of the builder.

Exceptions
Type Condition
ArgumentNullException
  • builder
  • content

SetContent<T>(T, Nullable<HttpContent>)

Sets the HTTP content which is being built.

Declaration
public static T SetContent<T>(this T builder, HttpContent? content)
    where T : IHttpContentBuilder
Parameters
Type Name Description
T builder

The builder.

Nullable<HttpContent> content

The new HTTP content. This can be null.

Returns
Type Description
T

The specified builder.

Type Parameters
Name Description
T

The type of the builder.

Exceptions
Type Condition
ArgumentNullException
  • builder

SetContent<T>(T, String, Nullable<Encoding>, Nullable<String>)

Sets the HTTP content to a new StringContent instance which is created from the specified content and encoding.

Declaration
public static T SetContent<T>(this T builder, string content, Encoding? encoding = default(Encoding? ), string? mediaType = default(string? ))
    where T : IHttpContentBuilder
Parameters
Type Name Description
T builder

The builder.

String content

The new HTTP content as a string.

Nullable<Encoding> encoding

The encoding to be used for converting the content to bytes. If null, the default value of the StringContent class is used.

Nullable<String> mediaType

The media type used by the content. If null, the default value of the StringContent class is used.

Returns
Type Description
T

The specified builder.

Type Parameters
Name Description
T

The type of the builder.

Exceptions
Type Condition
ArgumentNullException
  • builder
  • content

SetContentType<T>(T, Nullable<MediaTypeHeaderValue>)

Sets the Content-Type header of the HttpContentHeaders which are being built.

Declaration
public static T SetContentType<T>(this T builder, MediaTypeHeaderValue? contentType)
    where T : IHttpContentBuilder
Parameters
Type Name Description
T builder

The builder.

Nullable<MediaTypeHeaderValue> contentType

The value for the Content-Type header.

Returns
Type Description
T

The specified builder.

Type Parameters
Name Description
T

The type of the builder.

Exceptions
Type Condition
ArgumentNullException
  • builder

SetContentType<T>(T, String, Nullable<String>, Nullable<IEnumerable<NameValueHeaderValue>>)

Sets the Content-Type header of the HttpContentHeaders which are being built.

Declaration
public static T SetContentType<T>(this T builder, string mediaType, string? charSet = default(string? ), IEnumerable<NameValueHeaderValue>? parameters = default(IEnumerable<NameValueHeaderValue>? ))
    where T : IHttpContentBuilder
Parameters
Type Name Description
T builder

The builder.

String mediaType

The media-type of the Content-Type header.

Nullable<String> charSet

The character set of the Content-Type header. This can be null.

Nullable<IEnumerable<NameValueHeaderValue>> parameters

The media-type header value parameters of the Content-Type header. This can be null.

Returns
Type Description
T

The specified builder.

Type Parameters
Name Description
T

The type of the builder.

Exceptions
Type Condition
ArgumentNullException
  • builder

SetFormUrlEncodedContent<T>(T, IEnumerable<KeyValuePair<String, String>>)

Sets the HTTP content to a new FormUrlEncodedContent instance which is created from the specified content pairs.

Declaration
public static T SetFormUrlEncodedContent<T>(this T builder, IEnumerable<KeyValuePair<string, string>> content)
    where T : IHttpContentBuilder
Parameters
Type Name Description
T builder

The builder.

IEnumerable<KeyValuePair<String, String>> content

A set of key/value pairs which make up the form encoded HTTP content.

Returns
Type Description
T

The specified builder.

Type Parameters
Name Description
T

The type of the builder.

Exceptions
Type Condition
ArgumentNullException
  • builder
  • content

SetFormUrlEncodedContent<T>(T, IEnumerable<(String Key, String Value)>)

Sets the HTTP content to a new FormUrlEncodedContent instance which is created from the specified content pairs.

Declaration
public static T SetFormUrlEncodedContent<T>(this T builder, IEnumerable<(string Key, string Value)> content)
    where T : IHttpContentBuilder
Parameters
Type Name Description
T builder

The builder.

IEnumerable<ValueTuple<String, String>> content

A set of key/value pairs which make up the form encoded HTTP content.

Returns
Type Description
T

The specified builder.

Type Parameters
Name Description
T

The type of the builder.

Exceptions
Type Condition
ArgumentNullException
  • builder
  • content

SetFormUrlEncodedContent<T>(T, KeyValuePair<String, String>[])

Sets the HTTP content to a new FormUrlEncodedContent instance which is created from the specified content pairs.

Declaration
public static T SetFormUrlEncodedContent<T>(this T builder, params KeyValuePair<string, string>[] content)
    where T : IHttpContentBuilder
Parameters
Type Name Description
T builder

The builder.

KeyValuePair<String, String>[] content

A set of key/value pairs which make up the form encoded HTTP content.

Returns
Type Description
T

The specified builder.

Type Parameters
Name Description
T

The type of the builder.

Exceptions
Type Condition
ArgumentNullException
  • builder
  • content

SetFormUrlEncodedContent<T>(T, (String Key, String Value)[])

Sets the HTTP content to a new FormUrlEncodedContent instance which is created from the specified content pairs.

Declaration
public static T SetFormUrlEncodedContent<T>(this T builder, params (string Key, string Value)[] content)
    where T : IHttpContentBuilder
Parameters
Type Name Description
T builder

The builder.

ValueTuple<String, String>[] content

A set of key/value pairs which make up the form encoded HTTP content.

Returns
Type Description
T

The specified builder.

Type Parameters
Name Description
T

The type of the builder.

Exceptions
Type Condition
ArgumentNullException
  • builder
  • content
Back to top Copyright © 2019 ReqRest - Generated with DocFX - Material Theme made by Oscar Vásquez - Impressum (Imprint)