private void AppendHeaders(HttpRequestMessage request)
 {
     _setupContext.HeaderAccept().ForEach(x => request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(x)));
     _setupContext.HeaderAcceptEncoding().ForEach(x => request.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue(x)));
     _setupContext.HeaderAcceptCharset().ForEach(x => request.Headers.AcceptCharset.Add(new StringWithQualityHeaderValue(x)));
     _setupContext.HeaderForEverythingElse().ForEach(x => request.Headers.Add(x.Key, x.Value));
 }
예제 #2
0
 private void AppendHeaders(HttpRequestMessage request)
 {
     // httpclient default headers must be used because otherwise no value like "application/json;version=1" is allowed.
     _setupContext.HeaderAccept().ForEach(x => _httpClient.DefaultRequestHeaders.Add(HeaderType.Accept.Value, x));
     _setupContext.HeaderAcceptEncoding().ForEach(x => request.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue(x)));
     _setupContext.HeaderAcceptCharset().ForEach(x => request.Headers.AcceptCharset.Add(new StringWithQualityHeaderValue(x)));
     _setupContext.HeaderForEverythingElse().ForEach(x => request.Headers.Add(x.Key, x.Value));
 }
예제 #3
0
 private void AppendHeaders(HttpRequestMessage request)
 {
     _setupContext.HeaderAccept().ForEach(x => request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(x)));
     _setupContext.HeaderAcceptEncoding().ForEach(x => request.Headers.AcceptEncoding.Add(new StringWithQualityHeaderValue(x)));
     _setupContext.HeaderAcceptCharset().ForEach(x => request.Headers.AcceptCharset.Add(new StringWithQualityHeaderValue(x)));
     _setupContext.HeaderAuthorization().ForEach(x =>
     {
         var match = Regex.Match(x, "^\\s?(?<scheme>.*)\\s(?<parameter>.*)");
         request.Headers.Authorization = new AuthenticationHeaderValue(match.Groups["scheme"].Value, match.Groups["parameter"].Value);
     });
     _setupContext.HeaderForEverythingElse().ForEach(x => request.Headers.TryAddWithoutValidation(x.Key, x.Value));
 }