Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Conversation

@stephentoub
Copy link
Member

As with WinHttpHandler, CurlHandler wraps exceptions in HttpRequestException. But WinHttpHandler switches to using IOException when sending exceptions out via Stream.Read/WriteAsync. This change does the same for CurlHandler.

This also adds a test for #6231, which was correctly failing on Unix but with the wrong exception type (which is now the correct type with the previous commit).

cc: @davidsh, @joelverhagen, @ericeil, @kapilash

As with WinHttpHandler, CurlHandler wraps exceptions in HttpRequestException.  But WinHttpHandler switches to using IOException when sending exceptions out via Stream.Read/WriteAsync.  This change does the same for CurlHandler.
@stephentoub stephentoub changed the title Change CurlHandler to use IOExceptions for Stream failures Change CurlHandler to use IOExceptions for Stream failures Feb 19, 2016
writer.Write("HTTP/1.1 200 OK\r\n");
writer.Write($"Date: {DateTimeOffset.UtcNow:R}\r\n");
writer.Write("Content-Type: text/plain\r\n");
writer.Write($"Content-Length: {content.Length + 42}\r\n"); // incorrect length
Copy link
Member

Choose a reason for hiding this comment

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

I didn't think we were able to use this construct yet? The TFS mirrored builds are still C# 5, I think?

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed with #6181. Hence the very large #6209 😄

Copy link
Member

Choose a reason for hiding this comment

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

Ah, good to know.

@bartonjs
Copy link
Member

As long as it's not going to break the mirror, structurally LGTM.

@davidsh
Copy link
Contributor

davidsh commented Feb 19, 2016

Since this is part of unblocking an important scenario I am ok with it for now. I will try to add new capability to Azure within the next few days for this. In particular, we really need to test a few different "incomplete message read" scenarios. 'Content-Length' having length less than expected is one scenario. But there is also 'Transfer-Encoding: chunked' scenario where the connection is closed prior to the server sending the zero-length chunk. Finally, there is another response-test scenario where payload is sent without any Content-Length or Transfer-Encoding semantics. In that case, there is no "expected" playload length.


[ActiveIssue(6231, PlatformID.Windows)]
[Fact]
public async Task ReadAsStreamAsync_InvalidContentLengthResponse_ThrowsIOException()
Copy link
Contributor

Choose a reason for hiding this comment

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

I would change "InvalidContentLengthResponse" to "IncompleteContentLengthResponse"

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@stephentoub stephentoub force-pushed the curlhandler_ioexception branch from 563ccc5 to f9d4884 Compare February 19, 2016 22:32
stephentoub added a commit that referenced this pull request Feb 20, 2016
Change CurlHandler to use IOExceptions for Stream failures
@stephentoub stephentoub merged commit 4375b15 into dotnet:master Feb 20, 2016
@stephentoub stephentoub deleted the curlhandler_ioexception branch February 20, 2016 02:26
@karelz karelz modified the milestones: 1.0.0-rtm, 1.2.0 Dec 3, 2016
@karelz karelz added the os-linux Linux OS (any supported distro) label Mar 8, 2017
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…exception

Change CurlHandler to use IOExceptions for Stream failures

Commit migrated from dotnet/corefx@4375b15
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Building on PR dotnet/corefx#6250, added more response stream tests dealing with
invalid response body transfer semantics.


Commit migrated from dotnet/corefx@42e5f46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Net os-linux Linux OS (any supported distro)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants