ctx.Response.Send multiple times per connection?
See original GitHub issueHello Joel,
Me again (; Quick question, is there a way to use the Send command multiple times in a session? I am trying to stream MJPEG over HTTP 1.1 (Chunk method works perfect), but I don’t want to end the session after Send.
I.e.
byte[] jpeg = null;
while (true)
{
ctx.Response.Send(Encoding.ASCII.GetBytes(MJPEGHeader));
ctx.Response.Send(Encoding.ASCII.GetBytes("Content-length: " + jpeg.Length.ToString()));
jpeg = Get_Next_JPEG();
ctx.Response.Send(jpeg);
ctx.Response.Send(Encoding.ASCII.GetBytes(MJPEGFooter));
}
Thanks and sorry to bother so much!
Issue Analytics
- State:
- Created 3 years ago
- Comments:22 (16 by maintainers)
Top Results From Across the Web
How to use koa ctx body for multiple responses?
You can set ctx.body multiple times but only the last one will be used ... You can either concatenate your values in order...
Read more >Express.js - Sending Multiple HTTP Responses - Blog
response.send() sends the response and closes the connection, whereas with response.write() you can send multiple responses. In this article, I will explain ...
Read more >Response
Sending the response. The simplest way to send a response is to return a value from the route handler.
Read more >Response resolver - Basics
Response resolver. Response resolver is a function that accepts a captured request and may return a mocked response. Parameters.
Read more >How do you mock different responses in real life? #1117
Hello hello! I'm kinda new to this mocking thing, and I'm struggling implementing a proper developer experience to test different cases.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here you go! HttpServerLite is live on NuGet.
NuGet v1.0.0.16: https://www.nuget.org/packages/HttpServerLite/1.0.0.16 Commit: https://github.com/jchristn/HttpServerLite/commit/19a3e9569ce1c39250bbc3834c72b6baf878708f
Just some performance data for reference. WatsonWebserver smokes HttpServerLite in performance, but that’s to be expected - http.sys (used by Watson) is in the kernel, whereas HttpServerLite is 100% in user-space.
This is a simple test of 10 clients, 1000 requests, to a loopback endpoint (no content delivered). HttpServerLite is the top set, Watson is the bottom set. Net-net, Watson is 5x faster (average latency) and 3x throughput.
The second test was with some content being sent (JPG image). 1000 requests over 10 clients. Watson (bottom test) was again ~3x faster (latency) and >3x throughput.
I guess living in the kernel has its advantages. Still should be pretty fast (given the fact that it’s user space). I only have a few more things left to do to it and will report back here when it’s ready. I’m unlikely to make this the replacement for the innards of WatsonWebserver though because of the tremendous performance difference.