我的服务器正在向请求发送带有正文的示例响应标头:
static char* not_found_response_template =
"HTTP/1.1 404 Not Found\n"
"Content-type: text/html\n"
"\n"
"<html>\n"
" <body>\n"
" <h1>Not Found</h1>\n"
" <p>The requested URL was not found on this server.</p>\n"
" </body>\n"
"</html>\n";
len = strlen(not_found_response_template);
send(newSct, not_found_response_template, len, 0);
它正确发送它,但是firefox一直在加载,直到我取消转移。
firefox插件HttpRequestHelper显示了这个:
GET localhost:6666
- 回复 - 404未找到 内容类型:text / html
为什么没有加载内容?
答案 0 :(得分:5)
HTTP要求CR + LF终止行,因此请尝试\r\n
。
答案 1 :(得分:2)
发送响应后尝试刷新和/或关闭套接字。