-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Adding accept header to callsites within SignalR #55271
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
BrennanConroy
merged 47 commits into
dotnet:main
from
MattyLeslie:SignalR--Missing-Accept-Header
May 15, 2024
Merged
Changes from 42 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
9a06954
Adding accept header within NegotiateAsync() and default headers in C…
MattyLeslie 98f859f
Removing defaultRequestHeader for accept and focusing on setting the …
MattyLeslie b4bebb5
Removing the logic to clear accept headers before allocating the acce…
MattyLeslie 018350b
Adding accept header to LongPolling Get request within the Poll() method
MattyLeslie a6fc3e5
Adding the accept header to SendUtils call site.
MattyLeslie 6d793df
Added the accept header to the LongPolling callsite for the inital po…
MattyLeslie a56e8ed
Merge branch 'dotnet:main' into SignalR--Missing-Accept-Header
MattyLeslie 7576ac9
Removing whitespaces
MattyLeslie 168a108
Removing comment and fixing whitespace
MattyLeslie c3704ef
Correcting indentations
MattyLeslie e993ecc
retrigger checks
MattyLeslie a00806a
retrigger checks
MattyLeslie baea8dc
retrigger checks
MattyLeslie d5e1948
Merge branch 'dotnet:main' into SignalR--Missing-Accept-Header
MattyLeslie 335c09e
retrigger checks
MattyLeslie ead6b97
Merge branch 'dotnet:main' into SignalR--Missing-Accept-Header
MattyLeslie a0467c2
Removing default headers
MattyLeslie 9c214bb
adding tests for LongPollingTransport to check accept headers are set…
MattyLeslie feb1330
Adding tests for ServerSentEventsTransport to check accept headers ar…
MattyLeslie fafbd9f
Merge branch 'dotnet:main' into SignalR--Missing-Accept-Header
MattyLeslie 35614b7
Removing the Accept header addition for the SendDeleteRequestMethod()
MattyLeslie 39ddeb3
HttpConnection tests for NegotiateAsync
MattyLeslie 6c5dd09
Better method naming
MattyLeslie 0204a27
Improving LongPollingTransportTests
MattyLeslie 0b828ca
Creating accept header tests for the SendUtils
MattyLeslie 69dae2a
Improving ServerSentEventTests for accept header
MattyLeslie bd2609f
Adding an option parameter to HttpConnections contructor used for uni…
MattyLeslie d570d08
Addition of Test method to ensure NegotiateAsync() appends the correc…
MattyLeslie 6f84149
Removing changes related to injecting httpMessageHandler
MattyLeslie fe3a78a
Adjusting test to make use of httpmessageHandlerFactory and better pr…
MattyLeslie 50afbcb
Updating implementation for NegotiateAsyncAppendsCorrectAcceptHeader
MattyLeslie 0aaf06f
Uncommenting the addition of the accept header in NegotiateAsync()
MattyLeslie 14387c7
Final implementation for checking the correct header is appended to N…
MattyLeslie acbea26
Ensuring the TaskCompletionSource is allocated to
MattyLeslie f6c6b14
Merge branch 'dotnet:main' into SignalR--Missing-Accept-Header
MattyLeslie 824df9a
Merge branch 'SignalR--Missing-Accept-Header' of https://github.com/M…
MattyLeslie 4c8c275
Updating all TaskCompletionSources to run continuations asynchronously
MattyLeslie 64b15b9
Sorting headers
MattyLeslie fb4d3e2
SendUtils test to use testHttpHandler instead of moq
MattyLeslie a226948
ServerSentEvents headers test to use testHttpHandler instead of moq
MattyLeslie 1a5a21e
Improvement to PollRequestsContainCorrectAcceptHeader method to effec…
MattyLeslie 72b609a
Merge branch 'dotnet:main' into SignalR--Missing-Accept-Header
MattyLeslie d4e3f0c
Adding default timeouts
MattyLeslie 8df74b9
Sorting using statements and removing Moq
MattyLeslie bf623c0
Removing delay, only using secondRequestReceived, adding default time…
MattyLeslie f359abf
Merge branch 'SignalR--Missing-Accept-Header' of https://github.com/M…
MattyLeslie fe978ae
Adding default time to CompletionSource
MattyLeslie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/SignalR/clients/csharp/Client/test/UnitTests/SendUtilsTests.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.IO.Pipelines; | ||
using System.Net; | ||
using System.Net.Http; | ||
using System.Text; | ||
using Microsoft.AspNetCore.Http.Connections.Client.Internal; | ||
using Microsoft.AspNetCore.SignalR.Tests; | ||
using Moq; | ||
using Moq.Protected; | ||
using System.Net.Http.Headers; | ||
using Microsoft.AspNetCore.InternalTesting; | ||
MattyLeslie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
namespace Microsoft.AspNetCore.SignalR.Client.Tests; | ||
public partial class SendUtilsTests : VerifiableLoggedTest | ||
{ | ||
[Fact] | ||
public async Task SendMessagesSetsCorrectAcceptHeader() | ||
{ | ||
var testHttpHandler = new TestHttpMessageHandler(); | ||
var responseTaskCompletionSource = new TaskCompletionSource<HttpResponseMessage>(TaskCreationOptions.RunContinuationsAsynchronously); | ||
|
||
testHttpHandler.OnRequest((request, next, cancellationToken) => | ||
{ | ||
if (request.Headers.Accept?.Contains(new MediaTypeWithQualityHeaderValue("*/*")) == true) | ||
{ | ||
responseTaskCompletionSource.SetResult(ResponseUtils.CreateResponse(HttpStatusCode.OK)); | ||
} | ||
else | ||
{ | ||
responseTaskCompletionSource.SetResult(ResponseUtils.CreateResponse(HttpStatusCode.BadRequest)); | ||
} | ||
return responseTaskCompletionSource.Task; | ||
}); | ||
|
||
using (var httpClient = new HttpClient(testHttpHandler)) | ||
{ | ||
var pipe = new Pipe(); | ||
var application = new DuplexPipe(pipe.Reader, pipe.Writer); | ||
|
||
// Simulate writing data to send | ||
await application.Output.WriteAsync(Encoding.UTF8.GetBytes("Hello World")); | ||
application.Output.Complete(); | ||
|
||
await SendUtils.SendMessages(new Uri("http://fakeuri.org"), application, httpClient, logger: Logger).DefaultTimeout(); | ||
|
||
var response = await responseTaskCompletionSource.Task; | ||
Assert.Equal(HttpStatusCode.OK, response.StatusCode); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.