Skip to content

Fix User-Agent usage in SignalR #30764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 15, 2021
Merged

Fix User-Agent usage in SignalR #30764

merged 2 commits into from
Mar 15, 2021

Conversation

BrennanConroy
Copy link
Member

Fixes #30137
Fixes #29183

@BrennanConroy BrennanConroy added the area-signalr Includes: SignalR clients and servers label Mar 9, 2021
@BrennanConroy BrennanConroy added this to the 6.0-preview3 milestone Mar 9, 2021
@BrennanConroy BrennanConroy requested a review from davidfowl March 9, 2021 02:24
@BrennanConroy BrennanConroy requested a review from halter73 as a code owner March 9, 2021 02:24
@@ -608,6 +607,7 @@ private HttpClient CreateHttpClient()
// Check if the key is User-Agent and remove if empty string then replace if it exists.
if (string.Equals(header.Key, Constants.UserAgent, StringComparison.OrdinalIgnoreCase))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In WASM, the user would need to set "X-SignalR-User-Agent", whereas outside of WASM they need to set "User-Agent" to override the default we set. I could see us keeping this behavior, or saying "User-Agent" will apply to both.

@davidfowl
Copy link
Member

No test?

@BrennanConroy
Copy link
Member Author

No test?

I guess I can spend a couple hours trying to write a WASM test. Wont be able to test the other issue though, as that requires some version of mono.

@BrennanConroy BrennanConroy requested a review from a team as a code owner March 9, 2021 19:00
@BrennanConroy
Copy link
Member Author

No test?

Ok, some resemblance of a test added.

@@ -47,6 +50,12 @@
await hubConnection.SendAsync("SendMessage", "SignalR Client", $"Echo {transportType}");
}

protected async Task GetUserAgentHeader()
{
userAgent = await hubConnection.InvokeAsync<string>("GetHeaderValue", "X-SignalR-User-Agent");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like you want both user agents right? To make sure the normal is set as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normal is set by the browser, we shouldn't be testing browser behavior

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So before our code was just ineffective

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In WASM it was ineffective in some browsers, and set in others
Details at #29183 (comment)

@BrennanConroy BrennanConroy merged commit f04badc into main Mar 15, 2021
@BrennanConroy BrennanConroy deleted the brecon/ua branch March 15, 2021 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-signalr Includes: SignalR clients and servers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SignalR] Could not parse value for header 'User-Agent' grpc-dotnet + Blazor sets Safari and Firefox User-Agent to "grpc-dotnet/$assemblyVersion"
2 participants