Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The middleware blocks content streaming #63

Closed
alexanderm39 opened this issue May 23, 2018 · 2 comments
Closed

The middleware blocks content streaming #63

alexanderm39 opened this issue May 23, 2018 · 2 comments

Comments

@alexanderm39
Copy link

alexanderm39 commented May 23, 2018

Hi

Test code 1:

private static HttpClient Client { get; } = new HttpClient();
[HttpGet]
public async Task<FileStreamResult> Get()
{
    var stream = await Client.GetStreamAsync("http://ipv4.download.thinkbroadband.com/1GB.zip");

    return new FileStreamResult(stream, new MediaTypeHeaderValue("application/octet-stream"))
    {
        FileDownloadName = "bigfile.zip"
    };
}

Test code 2:

public async Task Post()
{
    var httpWriter = new StreamWriter(Response.Body);

    Response.ContentType = "text/event-stream";

    byte[] header = Encoding.ASCII.GetBytes("HELLO\n");

    await Response.Body.WriteAsync(header, 0, header.Length);

    await httpWriter.FlushAsync();

    try
    {
            await Run(httpWriter);
    }
    catch (Exception ex)
    {
        await httpWriter.WriteLineAsync(ex.ToString());
    }
}

private async Task Run(StreamWriter httpWriter)
{
    for (int i = 0; i < 50; i++)
    {
        await httpWriter.WriteAsync($"data: {i}\n\n");
        await httpWriter.FlushAsync();
        await Task.Delay(300);
    }
}
@Taritsyn
Copy link
Owner

Hello, Alex!

Thanks for information! This problem will require serious and long-term research.

But it seems to me, that the best variant for you would be to split your functionality into two web applications: user interface and streaming.

@Taritsyn
Copy link
Owner

Taritsyn commented Jul 4, 2018

Hello, Alex!

Try to upgrade to version 2.4.4.

@Taritsyn Taritsyn closed this as completed Jul 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants