POCO C ++库。获取完整的网址

时间:2017-05-29 19:35:35

标签: c++ poco-libraries

当我尝试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();
}

0 个答案:

没有答案