/// <summary> /// Sets the Referer header of the request to the specified value. /// </summary> /// <param name="value">The Referer header value.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest Referrer(this IWith @this, Uri value) => @this.Modify(request => request.Headers.Referrer = value);
/// <summary> /// Sets the Transfer-Encoding header of the request to the specified value. /// </summary> /// <param name="value">The Transfer-Encoding header value.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest TransferEncodingChunked(this IWith @this, bool value) => @this.Modify(request => request.Headers.TransferEncodingChunked = value);
/// <summary> /// Sets the header of the request to the specified name and values. /// </summary> /// <param name="name">The header name.</param> /// <param name="values">The header values.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest Header(this IWith @this, string name, params string[] values) => @this.Modify(request => request.Headers.Add(name, values));
/// <summary> /// Sets the Range header of the request to the specified value. /// </summary> /// <param name="value">The Range header value.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest Range(this IWith @this, RangeHeaderValue value) => @this.Modify(request => request.Headers.Range = value);
/// <summary> /// Adds a parameter to the query string of the request with the specified name. /// </summary> /// <param name="name">The parameter name.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest Query(this IWith @this, string name) => @this.Modify(request => request.RequestUri = AppendQuery(request.RequestUri, name));
/// <summary> /// Sets the content of the request to the specified content with values. /// </summary> /// <param name="content">The HTTP content.</param> /// <param name="values">The HTTP content to add to the collection.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> private static IRequest MultipartFormData(this IWith @this, MultipartFormDataContent content, params HttpContent[] values) => @this.Modify(SetMultipartFormDataContentWithValues(content, values));
/// <summary> /// Sets the Host header of the request to the specified value. /// </summary> /// <param name="value">The Host header value.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest Host(this IWith @this, string value) => @this.Modify(request => request.Headers.Host = value);
/// <summary> /// Sets the Content-MD5 header of the request to the specified value. /// </summary> /// <param name="value">The Content-MD5 header value.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest ContentMD5(this IWith @this, byte[] value) => @this.Modify(request => request.Content.Headers.ContentMD5 = value);
/// <summary> /// Sets the Expect header of the request to the specified value. /// </summary> /// <param name="value">The Expect header value.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest ExpectContinue(this IWith @this, bool value) => @this.Modify(request => request.Headers.ExpectContinue = value);
/// <summary> /// Sets the From header of the request to the specified value. /// </summary> /// <param name="value">The From header value.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest From(this IWith @this, string value) => @this.Modify(request => request.Headers.From = value);
/// <summary> /// Sets the Date header of the request to the specified value. /// </summary> /// <param name="value">The Date header value.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest Date(this IWith @this, DateTimeOffset value) => @this.Modify(request => request.Headers.Date = value);
/// <summary> /// Sets the Connection header of the request to the specified value. /// </summary> /// <param name="value">The Connection header value.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest ConnectionClose(this IWith @this, bool value) => @this.Modify(request => request.Headers.ConnectionClose = value);
/// <summary> /// Sets the Cache-Control header of the request to the specified value. /// </summary> /// <param name="value">The Cache-Control header value.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest CacheControl(this IWith @this, CacheControlHeaderValue value) => @this.Modify(request => request.Headers.CacheControl = value);
private static IRequest AddHeaderValue <T>(this IWith @this, Func <HttpRequestHeaders, ICollection <T> > selector, T value) => @this.Modify(request => selector(request.Headers).Add(value));
/// <summary> /// Sets the If-Range header of the request to the specified value. /// </summary> /// <param name="value">The If-Range header value.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest IfRange(this IWith @this, RangeConditionHeaderValue value) => @this.Modify(request => request.Headers.IfRange = value);
/// <summary> /// Sets the Content-Length header of the request to the specified value. /// </summary> /// <param name="value">The Content-Length header value.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest ContentLength(this IWith @this, long value) => @this.Modify(request => request.Content.Headers.ContentLength = value);
/// <summary> /// Sets the If-Unmodified-Since header of the request to the specified value. /// </summary> /// <param name="value">The If-Unmodified-Since header value.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest IfUnmodifiedSince(this IWith @this, DateTimeOffset value) => @this.Modify(request => request.Headers.IfUnmodifiedSince = value);
/// <summary> /// Sets the Content-Type header of the request to the specified value. /// </summary> /// <param name="value">The Content-Type header value.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest ContentType(this IWith @this, MediaTypeHeaderValue value) => @this.Modify(request => request.Content.Headers.ContentType = value);
/// <summary> /// Sets the Max-Forwards header of the request to the specified value. /// </summary> /// <param name="value">The Max-Forwards header value.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest MaxForwards(this IWith @this, int value) => @this.Modify(request => request.Headers.MaxForwards = value);
/// <summary> /// Adds a parameter to the query string of the request with the specified name and value. /// </summary> /// <param name="name">The parameter name.</param> /// <param name="value">The parameter value.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest Query(this IWith @this, string name, object value) => @this.Modify(request => request.RequestUri = AppendQuery(request.RequestUri, $"{name}={value}"));
/// <summary> /// Sets the Proxy-Authorization header of the request to the specified value. /// </summary> /// <param name="value">The Proxy-Authorization header value.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest ProxyAuthorization(this IWith @this, AuthenticationHeaderValue value) => @this.Modify(request => request.Headers.ProxyAuthorization = value);
/// <summary> /// Sets the content of the request to the specified content. /// </summary> /// <param name="content">The HTTP content.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest Content(this IWith @this, HttpContent content) => @this.Modify(request => request.Content = content);
/// <summary> /// Sets the HTTP version of the request to the specified version. /// </summary> /// <param name="version">The HTTP request version.</param> /// <returns>An <see cref="IRequest"/> object that represents the request.</returns> public static IRequest Version(this IWith @this, Version version) => @this.Modify(request => request.Version = version);