1

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...

Community
  • 1
  • 1
ren
  • 21
  • 1
  • 5
  • How do you envision using this? Most clients don't support trailers and intermediaries are likely to mess them up anyway. – EricLaw Jan 24 '15 at 20:22
  • I have a client that supports this. (Not a browser, though i'm not sure they don't support this feature). I am looking to send additinal data after streaming and it seems absurd to me that I should add another encoding/decoding layer, when the feature already exists in http. – ren Jan 25 '15 at 07:36

0 Answers0