Skip to content

Conversation

@Mpdreamz
Copy link
Member

@Mpdreamz Mpdreamz commented Jul 4, 2019

On .NET with our move to using non buffered writes to the stream I moved the GzipStream to wrap the stream passed to CompleteTaskOnCloseStream which was inadvertently breaking the stream becomming ready for writing resulting in no data being sent over the wire.

This PR also randomly enables HttpCompression on ConnectionSettings based on the test seed. Something I could have sworn was already in place but found only a TODO 😿

This commit removes adding Accept-Encoding headers again, when constructing the requestMessage.
These headers are added by the default HttpClientHandler implementation, with AutomaticDecompression.

There is the possibility that a user overrides CreateHttpClientHandler() and does not set AutomaticDecompression, but does not override CreateRequestMessage(), and is relying on CreateHttpRequestMessage to add the Accept-Encoding headers when using HttpCompression. This commit will break that usage pattern, but I think this is acceptable to do, because we should optimize for the default behaviour i.e. we _could_ check that Accept-Encoding headers have been set when HttpCompression is enabled, inside CreateHttpRequestMessage(), and set them if not, but this is additional overhead to perform on every request. Instead, a user overriding CreateHttpClientHandler() and not setting AutomaticDecompression, and not overriding CreateRequestMessage(), when wishing to use HttpCompression, should set AutomaticDecompression inside their overridden implementation.
Copy link
Contributor

@russcam russcam left a comment

Choose a reason for hiding this comment

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

LGTM. I pushed a small fix for setting Accept-Encoding headers twice

//.EnableHttpCompression()
.EnableHttpCompression(TestConfiguration.Instance.Random.HttpCompression)
#if DEBUG
.EnableDebugMode()
Copy link
Contributor

Choose a reason for hiding this comment

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

Not something to address in this PR, but this #if preprocessor directive to enable debug mode looks superfluous, because it's enabled already on line 45.

@russcam russcam merged commit e980fa1 into 7.x Jul 5, 2019
russcam pushed a commit that referenced this pull request Jul 5, 2019
)

* GzipStream was wrapping completed task handler not the writable stream
* Make sure HttpCompression is enabled randomly when running the integration tests
* Remove adding Accept-Encoding twice

This commit removes adding Accept-Encoding headers again, when constructing the requestMessage.
These headers are added by the default HttpClientHandler implementation, with AutomaticDecompression.

There is the possibility that a user overrides CreateHttpClientHandler() and does not set AutomaticDecompression, but does not override CreateRequestMessage(), and is relying on CreateHttpRequestMessage to add the Accept-Encoding headers when using HttpCompression. This commit will break that usage pattern, but I think this is acceptable to do, because we should optimize for the default behaviour i.e. we _could_ check that Accept-Encoding headers have been set when HttpCompression is enabled, inside CreateHttpRequestMessage(), and set them if not, but this is additional overhead to perform on every request. Instead, a user overriding CreateHttpClientHandler() and not setting AutomaticDecompression, and not overriding CreateRequestMessage(), when wishing to use HttpCompression, should set AutomaticDecompression inside their overridden implementation.

Fixes #3913
@russcam russcam deleted the fix/7.x/compression-dotnetcore branch July 5, 2019 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants