I Implemented a HttpListener
to process post requests. I need to stream data in the response and then send a trailer. See: HTTP Trailer Example
I've gone through the HttpListenerResponse Source Code to see if I can use reflection to trick it to send a trailer, which does not seem to be natively supported.
Here is a code sample of what I'm doing.
// setup response
_context.Response.SendChunked = true;
_context.Response.StatusCode = (int)HttpStatusCode.OK;
_context.Response.ContentEncoding = Encoding.UTF8;
_context.Response.ContentType = "application/octet-stream"; // "text/plain";
_context.Response.AddHeader("Trailer", "CRC");
// write bytes to output stream...
WriteStream(_context.Response.OutputStream);
// now what? -- this does not work...
_context.Response.AddHeader("CRC", "a trailer value goes here");
// close the response
_context.Response.Close();
Is there a way to do it? direct HttpAPI calls, Reflection, other suggestions...