public static async Task <Request> ToPipelineRequestAsync(this HttpRequestMessage request, HttpPipeline pipeline) { Request pipelineRequest = pipeline.CreateRequest(); pipelineRequest.Method = RequestMethod.Parse(request.Method.Method); pipelineRequest.Uri.Reset(request.RequestUri); pipelineRequest.Content = await request.Content.ToPipelineRequestContentAsync().ConfigureAwait(false); foreach (System.Collections.Generic.KeyValuePair <string, System.Collections.Generic.IEnumerable <string> > header in request.Headers) { foreach (var value in header.Value) { pipelineRequest.Headers.Add(header.Key, value); } } if (request.Content != null) { foreach (System.Collections.Generic.KeyValuePair <string, System.Collections.Generic.IEnumerable <string> > header in request.Content.Headers) { foreach (var value in header.Value) { pipelineRequest.Headers.Add(header.Key, value); } } } return(pipelineRequest); }
public static RecordEntry Deserialize(JsonElement element) { var record = new RecordEntry(); if (element.TryGetProperty(nameof(RequestMethod), out JsonElement property)) { record.RequestMethod = RequestMethod.Parse(property.GetString()); } if (element.TryGetProperty(nameof(RequestUri), out property)) { record.RequestUri = property.GetString(); } if (element.TryGetProperty("EncodedRequestUri", out property)) { record.IsTrack1Recording = true; } if (element.TryGetProperty("RequestHeaders", out property)) { DeserializeHeaders(record.Request.Headers, property); } if (element.TryGetProperty("RequestBody", out property)) { DeserializeBody(record.Request, property); } if (element.TryGetProperty(nameof(StatusCode), out property) && property.TryGetInt32(out var statusCode)) { record.StatusCode = statusCode; } if (element.TryGetProperty("ResponseHeaders", out property)) { DeserializeHeaders(record.Response.Headers, property); } if (element.TryGetProperty("ResponseBody", out property)) { DeserializeBody(record.Response, property); } return(record); }
public static async Task <Request> ToPipelineRequestAsync(this HttpRequestMessage request, HttpPipeline pipeline) { Request pipelineRequest = pipeline.CreateRequest(); pipelineRequest.Method = RequestMethod.Parse(request.Method.Method); pipelineRequest.UriBuilder.Uri = request.RequestUri; pipelineRequest.Content = await request.Content.ToPipelineRequestContentAsync().ConfigureAwait(false); foreach (var header in request.Headers) { foreach (var value in header.Value) { pipelineRequest.Headers.Add(header.Key, value); } } return(pipelineRequest); }
public void ParseReturnsCachedValue(RequestMethod method, string stringValue) { Assert.AreSame(method.Method, RequestMethod.Parse(stringValue).Method); }