@@ -22,9 +22,9 @@ internal static class SpaProxy
22
22
private const int DefaultWebSocketBufferSize = 4096 ;
23
23
private const int StreamCopyBufferSize = 81920 ;
24
24
25
- // Don't forward User-Agent because of https://github.com/aspnet/JavaScriptServices/issues/1469
25
+ // Don't forward User-Agent/Accept because of https://github.com/aspnet/JavaScriptServices/issues/1469
26
26
// Others just aren't applicable in proxy scenarios
27
- private static readonly string [ ] NotForwardedWebSocketHeaders = new [ ] { "Connection" , "Host" , "User-Agent" , "Upgrade" , "Sec-WebSocket-Key" , "Sec-WebSocket-Version" } ;
27
+ private static readonly string [ ] NotForwardedWebSocketHeaders = new [ ] { "Accept" , " Connection", "Host" , "User-Agent" , "Upgrade" , "Sec-WebSocket-Key" , "Sec-WebSocket-Version" } ;
28
28
29
29
public static HttpClient CreateHttpClientForProxy ( TimeSpan requestTimeout )
30
30
{
@@ -206,7 +206,19 @@ private static async Task<bool> AcceptProxyWebSocketRequest(HttpContext context,
206
206
{
207
207
if ( ! NotForwardedWebSocketHeaders . Contains ( headerEntry . Key , StringComparer . OrdinalIgnoreCase ) )
208
208
{
209
- client . Options . SetRequestHeader ( headerEntry . Key , headerEntry . Value ) ;
209
+ try
210
+ {
211
+ client . Options . SetRequestHeader ( headerEntry . Key , headerEntry . Value ) ;
212
+ }
213
+ catch ( ArgumentException )
214
+ {
215
+ // On net461, certain header names are reserved and can't be set.
216
+ // We filter out the known ones via the test above, but there could
217
+ // be others arbitrarily set by the client. It's not helpful to
218
+ // consider it an error, so just skip non-forwardable headers.
219
+ // The perf implications of handling this via a catch aren't an
220
+ // issue since this is a dev-time only feature.
221
+ }
210
222
}
211
223
}
212
224
0 commit comments