How to get Request-URI in RESPMOD?

Asked by johan

hi Alex and guys,

how I get uri request variable in ecap in respmod vectoring ?
for example when user request www.abc.net/urlpart.html
in adapter , i need to know full of uri part.
Thanks.

Johan

Question information

Language:
English Edit question
Status:
Answered
For:
eCAP Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Alex Rousskov (rousskov) said :
#1

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 and Host header values via firstLine() and header() methods.

Revision history for this message
johan (johanfirdi) said :
#2

I get error when compile following code,
here the error
error: ‘const class libecap::Message’ has no member named ‘FirstLine’
here the code
void Adapter::Xaction::noteVbContentAvailable()
{
const libecap::Area vb = hostx->vbContent(0, libecap::nsize); // get all vb
const libecap::Area hosturi = hostx->cause().FirstLine().uri();

        Must(receivingVb == opOn);
        if (sendingAb == opOn)
                hostx->noteAbContentAvailable();
using namespace std;
         ofstream myfile;
        myfile.open ("/tmp/vb.txt",ios::out|ios::binary|ios::app);
// myfile << hosturi.toString();
        myfile << vb.toString();
        myfile.close();

}

there's something wrong ?
any idea ?
Thanks.

Johan

Revision history for this message
Alex Rousskov (rousskov) said :
#3

The Message method is called firstLine and not FirstLine.

Revision history for this message
johan (johanfirdi) said :
#4

Thanks Alex for correction.
Next, what member i should use ?
I tried hostx->cause().firstLine().header().value(uriname), get error.
error: ‘const class libecap::FirstLine’ has no member named ‘header’

if i tried hostx->cause().firstLine().uri() get error too
error: ‘const class libecap::FirstLine’ has no member named 'uri’

If i look at in libecap source, in header.h
class FirstLine {
        public:
                virtual ~FirstLine() {}

                virtual Version version() const = 0;
                virtual void version(const Version &aVersion) = 0;
                virtual Name protocol() const = 0;
                virtual void protocol(const Name &aProtocol) = 0;
};

class RequestLine: public FirstLine {
        public:
                virtual ~RequestLine() {}

                virtual void uri(const Area &aUri) = 0;
                virtual Area uri() const = 0;

                virtual void method(const Name &aMethod) = 0;
                virtual Name method() const = 0;
};

On Tue, Jul 7, 2009 at 12:07 PM, Alex
Rousskov<email address hidden> wrote:
> Your question #76192 on eCAP changed:
> https://answers.launchpad.net/ecap/+question/76192
>
> Status: Open => Answered
>
> Alex Rousskov proposed the following answer:
> The Message method is called firstLine and not FirstLine.
>
> --
> If this answers your question, please go to the following page to let us
> know that it is solved:
> https://answers.launchpad.net/ecap/+question/76192/+confirm?answer_id=2
>
> If you still need help, you can reply to this email or go to the
> following page to enter your feedback:
> https://answers.launchpad.net/ecap/+question/76192
>
> You received this question notification because you are a direct
> subscriber of the question.
>

Revision history for this message
Alex Rousskov (rousskov) said :
#5

To get to the RequestLine::uri() method, you need to dynamic_cast the generic FirstLine pointer or reference to specific RequestLine pointer or reference. FirstLine class does not have a uri() method because only requests have URIs. Similarly, only ResponseLine can deal with response status codes.

Revision history for this message
Alex Rousskov (rousskov) said :
#6

Alex Rousskov suggests this article as an answer to your question:
FAQ #1576: “How to get requested URL?”.

Can you help with this problem?

Provide an answer of your own, or ask johan for more information if necessary.

To post a message you must log in.