Skip to content

Issue with ODataResponse #15

@neerajks

Description

@neerajks

Hi,
First of all let me thank you for a fantastic library.

I recently was using the beta version of the library for a project and got stuck with the following issue.
I have noticed a small issue in ODataResponseMessage GetStreamAsync Method.
dotnetstandard 2 onwards HttpResponseMessage.Content directly supports the ReadAsStreamAsync method. Hence the typecast to StreamContent. The above typecase fails as the response.Content is of type NoWriteNoSeekStreamContent. So propose the following change

As is:

public Task GetStreamAsync()
{
var responseContent = _response.Content as StreamContent;
if (responseContent != null)
{
return responseContent.ReadAsStreamAsync();
}
else
{
var completionSource = new TaskCompletionSource();
completionSource.SetResult(Stream.Null);
return completionSource.Task;
}
}

To be:

public Task GetStreamAsync()
{
var responseContent = _response.Content;
if (responseContent != null)
{
return responseContent.ReadAsStreamAsync();
}
else
{
var completionSource = new TaskCompletionSource();
completionSource.SetResult(Stream.Null);
return completionSource.Task;
}
}

Do let me know your thoughts.
Thanks,
Neeraj

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions