/// <summary> /// Constructor for HttpClientRequestMessage. /// </summary> /// <param name="client">The client</param> /// <param name="args">The args</param> /// <param name="config">The config</param> public HttpClientRequestMessage(HttpClient client, DataServiceClientRequestMessageArgs args, DataServiceClientConfigurations config) : base(args.ActualMethod) { this.requestMessage = new HttpRequestMessage(); // TODO, avoid create Memory Stream each time, consider object pooling this.messageStream = new MemoryStream(); this.contentHeaderValueCache = new Dictionary <string, string>(); foreach (var header in args.Headers) { this.SetHeader(header.Key, header.Value); } this.Url = args.RequestUri; this.Method = args.Method; this.config = config; // link http and odata properties to share state between odata and http handlers /* * TODO: UNCOMMENT this after properties is supported * if (config.Properties != null) * { * foreach (var item in config.Properties) * { * this.requestMessage.Properties[item.Key] = item.Value; * } * } */ this.client = client; }
public HttpClientResponseMessage(HttpResponseMessage httpResponse, DataServiceClientConfigurations config) : base(httpResponse.ToStringDictionary(), (int)httpResponse.StatusCode, () => { var task = httpResponse.Content.ReadAsStreamAsync(); task.Wait(); return(task.Result); }) { }