Reputation: 3625
I have copied the files (the ones from the "HTTP Server") from this tutorial, but it seems that it is not working. I have run the application with 0.0.0.0 5000 .
, but when I try to connect to the page localhost:5000 I get always 404 Not Found. What to do to make it run?
Upvotes: 0
Views: 889
Reputation: 51891
If you are getting an HTTP response with status code of 404, then the HTTP server is running, handling the request, and serving a response. If the server was not running, then an HTTP response would not be returned. The browser may provide additional details about the failure:
$ 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
Verify that the path being requested in the HTTP request exists in the directory that corresponds to the doc_root
parameter provided when starting the server. Also, be aware that if the request path ends with /
, then the server will append index.html
to the path. As seen in the code, if the server fails to open the file specified by the path, then the server will respond with an HTTP response having a 404 status code.
// 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;
}
Upvotes: 3