Boost http服务器示例不起作用
Boost http server example not working?
我已经从本教程中复制了文件(来自"HTTP服务器"的文件),但它似乎不起作用。我已经使用0.0.0.0 5000 .
运行了应用程序,但当我尝试连接到页面localhost:5000时,我总是得到404 Not Found。如何使其运行?
如果您得到一个状态代码为404的HTTP响应,那么HTTP服务器正在运行、处理请求并提供响应。如果服务器没有运行,则不会返回HTTP响应。浏览器可能会提供有关故障的其他详细信息:
$ lsof -i tcp:5000 # verify nothing is listening to port 5000
$ curl http://localhost:5000/
curl: (7) Failed to connect to localhost port 5000: Connection refused
验证HTTP请求中请求的路径是否存在于启动服务器时提供的doc_root
参数对应的目录中。此外,请注意,如果请求路径以/
结束,则服务器将把index.html
附加到该路径。如代码中所示,如果服务器未能打开路径指定的文件,则服务器将使用具有404状态代码的HTTP响应进行响应。
// Open the file to send back.
std::string full_path = doc_root_ + request_path;
std::ifstream is(full_path.c_str(), std::ios::in | std::ios::binary);
if (!is)
{
rep = reply::stock_reply(reply::not_found);
return;
}
相关文章:
- 我的神经网络不起作用 [XOR 问题]
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- C++映射:具有自定义类的运算符[]不起作用(总是返回0)
- C++为什么尽管我调用了void函数,它却不起作用
- 为什么在保护模式下继承升级不起作用
- 循环在计数器中不起作用
- 在其他文件中创建类时在 c++ 项目中不起作用
- Visual studio代码重构似乎不起作用(例如,重命名符号-f2)
- 为什么二进制搜索在我的测试中不起作用
- 我的代码中有错误吗?使用BGI图形的C++代码对我不起作用
- 为什么 const std::p air<K,V>& 在 std::map 上基于范围的 for 循环不起作用?
- 带有指定长度字符* 参数的 std::regex_search 在 VS2017 中不起作用?
- Bjarne Stroustrup Book - std_lib_facilities.h - 不起作用(未知类型名称)
- 我正在开发服务器,ip作为参数传递不起作用
- 尝试将C++代码移植到服务器以将文件上传到Objective-C,但它不起作用
- Boost http服务器示例不起作用
- 使用 C/C++、SSL 协议的客户端和服务器通信不起作用
- 为什么客户端/服务器机制(使用套接字)不起作用?
- C ++中的简单客户端服务器程序不起作用
- 客户端和服务器示例不起作用