当我尝试getUri
回复时,我只获得了uri路径。有没有办法从HTTPResponse
获取uri片段?
class TestMyRequestHandler : public HTTPRequestHandler
{
public:
void handleRequest(HTTPServerRequest &req, HTTPServerResponse &resp)
{
resp.setStatus(HTTPResponse::HTTP_OK);
resp.setContentType("text/html");
ostream& out = resp.send();
URI uri(req.getURI());
clog << uri.toString() << endl;
}
};
class TestRequestHandlerFactory : public HTTPRequestHandlerFactory
{
public:
virtual HTTPRequestHandler* createRequestHandler(const HTTPServerRequest &)
{
return new TestMyRequestHandler;
}
};
int main()
{
HTTPServer test(new TestRequestHandlerFactory, ServerSocket(8080), new HTTPServerParams);
test.start();
for(;;)
{
}
test.stop();
}