@@ -22,9 +22,9 @@ internal static class SpaProxy
2222 private const int DefaultWebSocketBufferSize = 4096 ;
2323 private const int StreamCopyBufferSize = 81920 ;
2424
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
2626 // 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" } ;
2828
2929 public static HttpClient CreateHttpClientForProxy ( TimeSpan requestTimeout )
3030 {
@@ -206,7 +206,19 @@ private static async Task<bool> AcceptProxyWebSocketRequest(HttpContext context,
206206 {
207207 if ( ! NotForwardedWebSocketHeaders . Contains ( headerEntry . Key , StringComparer . OrdinalIgnoreCase ) )
208208 {
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+ }
210222 }
211223 }
212224
0 commit comments