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.
DefaultResponseFactorywas 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 theHttpClientcannot 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
TransportResponseis a tweak for the ingest work. TheBulkStreamingResponsewas initially derived from theStreamResponseto share behaviour. However, this causes theBodyproperty (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,BulkStreamingResponsederives directly fromTransportResponse, overridingLeaveOpenand handlingLinkedDisposablesin its ownDisposemethod.This means we could potentially seal
StreamResponseagain. 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?