在 header 回复中回复 SUCCESS

Respond with SUCCESS in header reply

我正在使用以下内容响应来自现场设备的 GET 请求:

var reply = new HttpResponseMessage(System.Net.HttpStatusCode.OK)                
{
   Content = new StringContent("SUCCESS")
};

该词出现在 body 的消息中。但是现场设备说它没有成功。

据此,我可以推断出我不应该使用 HttpResponseMessage,而应该使用其他一些方法。

建议的回复需要如下所示:

HTTP/1.1 200 OK<CR><LF>
Date: Mon, 15 Feb 2016 11:34:50 GMT<CR><LF>
Server: Apache/2.2.31 (Win32) mod_ssl/2.2.31 OpenSSL/1.0.2f PHP/5.4.45<CR><LF>
X-Powered-By: PHP/5.4.45<CR><LF>
Content-Length: 7<CR><LF>
Keep-Alive: timeout=5, max=100<CR><LF>
Connection: Keep-Alive<CR><LF>
Content-Type: text/plain<CR><LF>
<CR><LF>
SUCCESS<CR><LF>

顺便说一句,我使用的不是 Microsoft PHP,而是来自手册。

我应该使用 HttpRequestMessage 吗?

我关心的部分是<CR><LF>SUCCESS<CR><LF>

所以问题是设备需要与我的服务器进行时间同步才能稍后发送数据。因此,响应从来没有问题。