@@ -55,8 +55,8 @@ public HttpClientRequester(HttpClient client)
55
55
/// </returns>
56
56
public Boolean SupportsProtocol ( String protocol )
57
57
{
58
- return protocol . Equals ( "http" , StringComparison . OrdinalIgnoreCase ) ||
59
- protocol . Equals ( "https" , StringComparison . OrdinalIgnoreCase ) ;
58
+ return protocol . Equals ( ProtocolNames . Http , StringComparison . OrdinalIgnoreCase ) ||
59
+ protocol . Equals ( ProtocolNames . Https , StringComparison . OrdinalIgnoreCase ) ;
60
60
}
61
61
62
62
/// <summary>
@@ -79,7 +79,9 @@ public async Task<IResponse> RequestAsync(IRequest request, CancellationToken ca
79
79
// Source:
80
80
// https://github.com/aspnet/Mvc/blob/02c36a1c4824936682b26b6c133d11bebee822a2/src/Microsoft.AspNet.Mvc.WebApiCompatShim/HttpRequestMessage/HttpRequestMessageFeature.cs
81
81
if ( ! requestMessage . Headers . TryAddWithoutValidation ( header . Key , header . Value ) )
82
+ {
82
83
contentHeaders . Add ( new KeyValuePair < String , String > ( header . Key , header . Value ) ) ;
84
+ }
83
85
}
84
86
85
87
// set up the content
@@ -88,7 +90,9 @@ public async Task<IResponse> RequestAsync(IRequest request, CancellationToken ca
88
90
requestMessage . Content = new StreamContent ( request . Content ) ;
89
91
90
92
foreach ( var header in contentHeaders )
93
+ {
91
94
requestMessage . Content . Headers . TryAddWithoutValidation ( header . Key , header . Value ) ;
95
+ }
92
96
}
93
97
94
98
// execute the request
@@ -102,12 +106,17 @@ public async Task<IResponse> RequestAsync(IRequest request, CancellationToken ca
102
106
StatusCode = responseMessage . StatusCode
103
107
} ;
104
108
105
- if ( responseMessage . Content != null )
109
+ // get the anticipated content
110
+ var content = responseMessage . Content ;
111
+
112
+ if ( content != null )
106
113
{
107
- response . Content = await responseMessage . Content . ReadAsStreamAsync ( ) . ConfigureAwait ( false ) ;
114
+ response . Content = await content . ReadAsStreamAsync ( ) . ConfigureAwait ( false ) ;
108
115
109
- foreach ( var pair in responseMessage . Content . Headers )
116
+ foreach ( var pair in content . Headers )
117
+ {
110
118
response . Headers [ pair . Key ] = String . Join ( ", " , pair . Value ) ;
119
+ }
111
120
}
112
121
113
122
return response ;
0 commit comments