Denormalize "Code", slight simplification of HTTP interface #224
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.
Sorry that this is kind of a large PR. The main intent was the first bullet, but I tackled some other things that I think are improvements along the way.
StreamResult.Complete
andResponseMessage
, even though it was redundant with the code on any non-nullConnectException
.Code.OK
. It is now just an error code. An "OK" result is easily distinguished by the lack of an exception.HTTPClientInterface
was previously responsible for translating HTTP status ->Code
and theHTTPResponse
reported back the status in an optional "trace info" field. But translating status toCode
should be the responsibility of the protocol implementations, not the HTTP client. (Though it is still up to the HTTP client to classify exceptions that prevent an HTTP response from being received, as these could be client-implementation-specific exception types). So this change promotes the status code out of trace info and into theHTTPResponse
.ProtocolClient.stream
usedsuspendCancellableCoroutine
incorrectly. It looks like it was trying to associate the stream with the coroutine, so if the coroutine is cancelled then the stream is closed. But it is only effective while that method is running, which is almost none at all since it immediately returns a result (no suspensions).There are some other small clean-ups in here, too, like moving some things around to places that (IMO) make more sense.