-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Implementations of new HttpContent sync methods. #38635
Merged
ManickaP
merged 15 commits into
dotnet:master
from
ManickaP:mapichov/37477_sync_http_contents
Jul 10, 2020
+241
−39
Merged
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
196cebe
WinHttpHandler NoWriteNoSeekStreamContent sync API.
ManickaP 7fa4d49
JsonContent and DecompressionHandlerContent sync.
ManickaP 4635ab6
Utf8StringContent sync
ManickaP 7ff4989
net fw compilaris
ManickaP 775664f
Reverted WinHttpHandler changes.
ManickaP 14eae27
Decompression tests for sync send.
ManickaP 6e90249
JsonContent PR feedback.
ManickaP aa915d5
Updated ref sources for HttpContents.
ManickaP 4505b53
Fixed test compilation for net fw, added and improved json content te…
ManickaP 96f6ac0
Utf8 tests added and fixed.
ManickaP bc77fbb
net fx compilation
ManickaP 6d34cfc
PR feedback.
ManickaP 7cb03ab
whitespaces and vars.
ManickaP d927afc
Merge branch 'master' into mapichov/37477_sync_http_contents
ManickaP 01be142
Addressed PR feedback.
ManickaP 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 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 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 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 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 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 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 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 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
33 changes: 33 additions & 0 deletions
33
src/libraries/System.Net.Http.Json/tests/FunctionalTests/JsonContentTests.netcoreapp.cs
This file contains 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,33 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.IO; | ||
using System.Net.Http.Headers; | ||
using System.Net.Test.Common; | ||
using System.Runtime.CompilerServices; | ||
using System.Text; | ||
using System.Text.Json; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
|
||
namespace System.Net.Http.Json.Functional.Tests | ||
{ | ||
public class JsonContentTests_Sync : JsonContentTestsBase | ||
{ | ||
protected override Task<HttpResponseMessage> SendAsync(HttpClient client, HttpRequestMessage request) => Task.Run(() => client.Send(request)); | ||
|
||
[Fact] | ||
public void JsonContent_CopyTo_Succeeds() | ||
{ | ||
var person = Person.Create(); | ||
ManickaP marked this conversation as resolved.
Show resolved
Hide resolved
|
||
using var content = JsonContent.Create(person); | ||
ManickaP marked this conversation as resolved.
Show resolved
Hide resolved
|
||
using var stream = new MemoryStream(); | ||
content.CopyTo(stream, null, default); | ||
ManickaP marked this conversation as resolved.
Show resolved
Hide resolved
ManickaP marked this conversation as resolved.
Show resolved
Hide resolved
ManickaP marked this conversation as resolved.
Show resolved
Hide resolved
|
||
stream.Seek(0, SeekOrigin.Begin); | ||
using var reader = new StreamReader(stream); | ||
var json = reader.ReadToEnd(); | ||
ManickaP marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Assert.Equal(person.Serialize(JsonOptions.DefaultSerializerOptions), json); | ||
} | ||
} | ||
} |
This file contains 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this accomplishing? Shouldn't the client's
DefaultRequestVersion
be the same asremoteServer.HttpVersion
here?HttpClient
does essentially the same thing as thisCreateRequest
when you callGetAsync
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SendAsync|Send
ignoresHttpClient.DefaultRequestVersion
since it accepts fully constructed request. The default initialization ofHttpRequestMessage
will set it to 1.1. And because we plug inVersionChecker
set up with the remote server version, it will blow up for 2.0 servers.If it's about why
Send
versusGet
, then it's because we weren't testing decompression with sync code paths at all due to usingGetAsync
(helpers didn't get sync overloads). And we had an error in missing overrides for decompression content 😞 So I changed the tests to useSendAsync|Send
instead and now we're testing both, sync and async.