How an adapter can get requested URL?

Created by Alex Rousskov
Keywords:
Last updated by:
Alex Rousskov

libecap::host::Xaction::virgin() method gives access to the request message in REQMOD.
libecap::host::Xaction::cause() method gives access to the request message in RESPMOD.

Once you have the request message, you can access its Request-URI via the firstLine() method:

    libecap::Area uri;
    typedef const libecap::RequestLine *CLRLP;
    if (CLRLP requestLine = dynamic_cast<CLRLP>(&hostx->virgin().firstLine()))
            uri = requestLine->uri();
    else
    if (CLRLP requestLine = dynamic_cast<CLRLP>(&hostx->cause().firstLine()))
            uri = requestLine->uri();

The above working example handles both REQMOD and RESPMOD and is taken from the Adapter::Xaction::getUri() method in the ClamAV adapter.