/// <summary> /// Initializes a new instance of the WebApiClientRequest class. /// </summary> /// <param name="httpMethod">The HTTP method</param> /// <param name="uri">The URI</param> /// <param name="mediaType">The media type</param> /// <param name="headers">The request headers</param> /// <param name="formatter">Media Type Formatter</param> /// <param name="clientName">Client Name</param> /// <param name="operationName">Operation Name</param> public WebApiClientRequest(HttpMethod httpMethod, Uri uri, string mediaType, NameValueCollection headers = null, MediaTypeFormatter formatter = null, string clientName = null, string operationName = null) { this.Method = httpMethod; this.Uri = uri; this.MediaType = mediaType; this.Headers = ClientHeaders.FromNameValueCollection(headers); this.Formatter = formatter; this.ClientName = clientName; this.OperationName = operationName; }
/// <summary> /// Initializes a new instance of the ClientParameters class /// </summary> protected ClientParameters() { if (this.Headers == null) { this.Headers = new ClientHeaders(); } // TODO mayuro: Defaults should come from config this.MaxResponseContentBufferSizeInBytes = 1048576; // this.Headers.Version = "2013-08-01"; }
/// <summary> /// Converts a HttpHeaders collection to a ClientHeaders collection. /// </summary> /// <param name="headers">The HttpHeaders to convert.</param> /// <returns>A ClientHeaders collection corresponding to the specified headers.</returns> public static ClientHeaders ToNameValueCollection(this HttpHeaders headers) { var newHeaders = new ClientHeaders(); foreach (var header in headers) { foreach (string headerValue in header.Value) { newHeaders.Add(header.Key, headerValue); } } return(newHeaders); }
/// <summary> /// Converts a NameValueCollection into a new ClientHeaders collection. /// </summary> /// <param name="headers">The NameValueCollection to convert</param> /// <returns>A new ClientHeaders collection</returns> public static ClientHeaders FromNameValueCollection(NameValueCollection headers) { var clientHeaders = new ClientHeaders(); if (headers != null) { for (int i = 0; i < headers.Count; i++) { clientHeaders.Set(headers.GetKey(i), headers.Get(i)); } } return(clientHeaders); }
/// <summary> /// Initializes a new instance of the <see cref="WebApiClientResponse" /> class. /// </summary> public WebApiClientResponse() { this.Headers = new ClientHeaders(); }