You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@trafficserver.apache.org by Dk Jack <dn...@gmail.com> on 2016/05/27 02:07:09 UTC

atscppapi question

Hi,
I am using atscppapi in my plugin. I send a curl request as follows to ATS:

    curl 'http://localhost:8080/abcdef?a=1&b=2'

In my plugin code, in handleReadRequestHeadersPreRemap function, I am
printing the following:

logInfo("effective-url: %s", txn.getEffectiveUrl().c_str());

ClientRequest& request = txn.getClientRequest();
Url& url = request.getUrl();
logInfo("url: %s", url.getUrlString().c_str());
logInfo("host: %s", url.getHost().c_str());
logInfo("path: %s", url.getPath().c_str());

What gets print is as follows:

effective-url: http://localhost/abcdef?a=1&b=2
url: None
host: ''
path: abcdef

The 'url' and 'host' are empty. Could someone explain the reason for this?
How can get the correct
url and host to be printed?

Any help is appreciated. Thanks

Dk

Re: atscppapi question

Posted by Dk Jack <dn...@gmail.com>.
Alan,
I have web-server behind ats. I was trying print various request attributes in my plugin. 

curl -v showed that it's sending the correct headers. I even collected tcpdump of the exchange and I see the complete URL being sent. The host header has the correct info. When I use the getHost API I get an empty string. I expected to see 'localhost' since the effective URL has local host in the host portion of the URL. I haven't tried to print the host header. I'll try that next. 

Dk



> On May 27, 2016, at 8:30 AM, Alan Carroll <so...@yahoo-inc.com.INVALID> wrote:
> 
> I'm not sure what you're trying to do with that curl command. ATS is a proxy which means it has no content, it expects to forward any request on to an origin server. What origin server are you trying to reach via ATS? Normally I would do something like
> 
> curl --proxy localhost:8080 Apache Traffic Server
> 
> 
> I also recommend the "--verbose" option so you can see what curl is actually sending.
> 
> Additionally you could try some of the example CPP API plugins, at least one of which does a similar print and see what results you get from that.

Re: atscppapi question

Posted by Alan Carroll <so...@yahoo-inc.com.INVALID>.
curl --proxy localhost:8080 http://trafficserver.apache.org



Thank you, helpful mail program.

Re: atscppapi question

Posted by Alan Carroll <so...@yahoo-inc.com.INVALID>.
I'm not sure what you're trying to do with that curl command. ATS is a proxy which means it has no content, it expects to forward any request on to an origin server. What origin server are you trying to reach via ATS? Normally I would do something like

curl --proxy localhost:8080 Apache Traffic Server

   
I also recommend the "--verbose" option so you can see what curl is actually sending.

Additionally you could try some of the example CPP API plugins, at least one of which does a similar print and see what results you get from that.