Null check bug fixes and tweak accessibility of properties on TransportResponse
#144
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.
DefaultResponseFactory
was throwing if the response stream was null. This can occur when an exception is thrown when sending the request (e.g.,HttpRequestException
), for example, when theHttpClient
cannot connect to the endpoint. Rather than throwing a null exception here, we still want to return a response with the original exception attached.In
StreamResponse
, we must safety-check that any linked disposables are not null before attempting to dispose of them.The final change in
TransportResponse
is a tweak for the ingest work. TheBulkStreamingResponse
was initially derived from theStreamResponse
to share behaviour. However, this causes theBody
property (stream) to be present on the derived type. As we are handling stream reading internally, this is unnecessary and could produce weird behaviour if the consumer tries to access the stream directly. Instead,BulkStreamingResponse
derives directly fromTransportResponse
, overridingLeaveOpen
and handlingLinkedDisposables
in its ownDispose
method.This means we could potentially seal
StreamResponse
again. However, it might still be helpful for consumers to derive responses from this for advanced scenarios, with the base class doing the right thing during disposal. I am open to thoughts on whether that's likely to happen. @flobernd, were you deriving from this in the client?