Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

PushStreamContent with Post request

$
0
0

Hi,

I'm trying to utilize the PushStreamContent class to stream results of a big query back to the client.

I noticed that when I write results to the stream in the delegate passed to the ctor, the client never starts reading them until the server finishes writing all results to the stream and calls its Close() method.

After looking at some examples I couldn't figure out what I'm doing wrong, until I noticed something strange.

When debugging the client, the stream that I receive is always System.IO.MemeoryStream, meaning that HttpClient returns this stream from the call to HttpContent.ReadAsStreamAsync, and reads the entire response to that memory stream before the app can handle the response.

I found out that this happens because my request is sent as POST (I need to pass a complex object as a parameter to the controller action).

When I execute a GET, everything suddenly started to work.

Soooo, is this by design?

If so, how can I perform a GET with a complex object passed to the controller's GET method?

EDIT:

Apparently this happens whenever you call HttpContent.ReadAsStreamAsync(), no matter if the method is POST or GET.

The only way streaming works is when I call HttpClient.GetStreamAsync().

Is there any way I could achieve this with a POST request?


Viewing all articles
Browse latest Browse all 4850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>