Fixed deadlock when serializing content #590
Merged
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.
This fixes an issue that was discovered after pull request #571 was merged to master (MyGet version 4.6.66).
A request which contains a body that should be serialized (and is not a multi-part request) will deadlock in the PushStreamContent at:
refit/Refit/PushStreamContent.cs
Line 142 in 3fce69b
The PushStreamContent content type provides a stream to write to, but in order for it to complete the request it blocks until the stream is closed. The original implementation did this implicitly because a StreamWriter was used within a using block:
refit/Refit/RequestBuilderImplementation.cs
Lines 474 to 481 in e2e7975
I've added additional tests to make sure that the request doesn't block and it also checks the other flow through the RequestBuilderImplementation class where the request is not a multi-part request. I also fixed a typo in existing tests where a wrong exception was thrown.