/// <summary> /// Sets the "Referer" header of the address of the previous web page from which a link to the currently requested page was followed. /// </summary> /// <param name="settings">The settings.</param> /// <param name="url">the url to apply to the "refer" header</param> /// <returns>The same <see cref="HttpSettings"/> instance so that multiple calls can be chained.</returns> public static HttpSettings SetReferer(this HttpSettings settings, string url) { if (string.IsNullOrWhiteSpace(url)) { throw new ArgumentNullException(nameof(url)); } return(settings.AppendHeader("Referer", url)); }
/// <summary> /// Sets the "Accept-Language" header of the request. /// </summary> /// <param name="settings">The settings.</param> /// <param name="acceptLanguage">List of acceptable human languages for response.</param> /// <returns>The same <see cref="HttpSettings"/> instance so that multiple calls can be chained.</returns> public static HttpSettings SetAcceptLanguage(this HttpSettings settings, string acceptLanguage) { if (string.IsNullOrWhiteSpace(acceptLanguage)) { throw new ArgumentNullException(nameof(acceptLanguage)); } return(settings.AppendHeader("Accept-Language", acceptLanguage)); }
/// <summary> /// Sets the content-type of the request /// </summary> /// <param name="settings">The settings.</param> /// <param name="contentType">The MIME type of the body of the request (used with POST and PUT requests).</param> /// <returns>The same <see cref="HttpSettings"/> instance so that multiple calls can be chained.</returns> public static HttpSettings SetContentType(this HttpSettings settings, string contentType) { if (string.IsNullOrWhiteSpace(contentType)) { throw new ArgumentNullException(nameof(contentType)); } return(settings.AppendHeader("Content-Type", contentType)); }
/// <summary> /// Adds a Authorization Header to the request. /// </summary> /// <param name="settings">The settings.</param> /// <param name="schema">The scheme to use for authorization.</param> /// <param name="parameter">The credentials containing the authentication information of the user agent for</param> /// <returns>The same <see cref="HttpSettings"/> instance so that multiple calls can be chained.</returns> public static HttpSettings SetAuthorization(this HttpSettings settings, string schema, string parameter) { if (string.IsNullOrWhiteSpace(schema)) { throw new ArgumentNullException(nameof(schema)); } if (string.IsNullOrWhiteSpace(parameter)) { throw new ArgumentNullException(nameof(parameter)); } return(settings.AppendHeader("Authorization", $"{schema} {parameter}")); }
/// <summary> /// Appends a Cache-Control header with no-store /// </summary> /// <param name="settings">The settings.</param> /// <returns>The same <see cref="HttpSettings"/> instance so that multiple calls can be chained.</returns> public static HttpSettings SetNoCache(this HttpSettings settings) { return(settings.AppendHeader("Cache-Control", "no-store")); }