I am using C# HttpListener class to realize some server. And here is the problem. I just want to send to client an empty response to the request like
HTTP/1.1 200 OK
or
HTTP/1.1 400 Bad Request
without any additional text. So I set status code and status description and don't write any bytes to response OutputStream - I just don't need them. Then close the response to initiate sending bytes to the client with response.Close() method. And what I get on the client side shown by Fiddler is
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Server: Microsoft-HTTPAPI/2.0
Date: Sun, 25 Oct 2015 10:42:12 GMT
0
There is a workaround for Server and Date fields - HttpListener Server Header c#.
But how to remove these "Transfer-Encoding: chunked" artefact and "0" body from this response?!
Thanks to all in advance!
The code:
private void ProcessContext(HttpListenerContext aContext)
{
HttpListenerResponse response = aContext.Response;
response.StatusCode = (int)HttpStatusCode.OK;
response.StatusDescription = "OK";
response.Close();
}