【发布时间】:2013-03-26 22:57:15
【问题描述】:
我的服务器正在向请求发送带有正文的示例响应标头:
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 显示:
获取本地主机:6666
-- 响应-- 404 未找到 内容类型:text/html
为什么内容没有加载?
【问题讨论】:
-
对于 http 标头,使用 \r\n 行终止符。可能不是这样,但我在这里没有看到任何其他错误,并且标准要求协议流量使用 CRLF 终止符
标签: c http networking response