private async void HandleBody(XPHttpClientConfig config) { if (Body is HttpStringContent) { var content = await Body.ReadAsStringAsync(); if (ContentEncoding == null && MediaType == null) { if (config.ContentEncoding != null && config.MediaType != null) { Body = new HttpStringContent(content, config.ContentEncoding.Value, config.MediaType); } else if (config.ContentEncoding != null) { Body = new HttpStringContent(content, config.ContentEncoding.Value); } } else if (MediaType == null) { if (config.MediaType != null) { Body = new HttpStringContent(content, ContentEncoding.Value, config.MediaType); } } else if (ContentEncoding == null) { if (config.ContentEncoding != null) { Body = new HttpStringContent(content, config.ContentEncoding.Value, MediaType); } } else { Body = new HttpStringContent(content, ContentEncoding.Value, MediaType); } } }
internal void ApplyToRequester(HttpRequestMessage requester, XPHttpClientConfig config) { HandleBody(config); requester.Content = Body; foreach (var header in Headers) { requester.Headers.Append(header.Key, header.Value); } if (SchemeAuthorization != null && Authorization != null) { requester.Headers.Authorization = new HttpCredentialsHeaderValue(SchemeAuthorization, Authorization); } if (IfModifiedSince.HasValue) { requester.Headers.IfModifiedSince = new DateTimeOffset(IfModifiedSince.Value); } }