Re: Fetching URL contents in a plugin

2019-06-27 Thread Eric Friedrich
Thanks Aaron- That looks like exactly what I needed, AsyncHttpFetch actually fits better in the cpp API. --Eric On Thu, Jun 27, 2019 at 4:06 PM Aaron Canary wrote: > Alan, That not what he wants. > > Eric, When we prototyped some health check code we used *TSFetchUrl().* > See if that works

Re: Fetching URL contents in a plugin

2019-06-27 Thread Aaron Canary
Alan, That not what he wants. Eric, When we prototyped some health check code we used *TSFetchUrl().* See if that works for you. On Mon, Jun 24, 2019 at 10:47 AM Alan Carroll wrote: > My mistake, TSHttpTxnEffectiveUrlStringGet is documented here - > > https://docs.trafficserver.apache.org/en/

Re: Fetching URL contents in a plugin

2019-06-24 Thread Alan Carroll
My mistake, TSHttpTxnEffectiveUrlStringGet is documented here - https://docs.trafficserver.apache.org/en/8.0.x/developer-guide/api/functions/TSUrlStringGet.en.html#c.TSHttpTxnEffectiveUrlStringGet On Mon, Jun 24, 2019 at 10:08 AM Alan Carroll < solidwallofc...@verizonmedia.com> wrote: > I am lite

Re: Fetching URL contents in a plugin

2019-06-24 Thread Alan Carroll
I am literally working with this right now, I will send an update when I have the code in a good state. Turns out that, for no apparent reason, TSIOBufferSizedCreate asserts if the requested size is more than 32K. Although in practice that's likely to be enough. Perhaps TSHttpTxnEffectiveUrlStringG

Re: Fetching URL contents in a plugin

2019-06-21 Thread Alan Carroll
> > Yes, it's a problem that TSIOBufferReaderRead doesn't exist yet. What you > should do is > TSIOBufferBlock block = TSIOBufferStart(iobuff); char const* text = TSIOBufferBlockReadStart(block); text now points at the URL string. For the length you can use TSUrlLengthGet() or TSIOBufferReadAvail

Re: Fetching URL contents in a plugin

2019-06-21 Thread Eric Friedrich -X (efriedri - TRITON UK BIDCO LIMITED c/o Alter Domus (UK) Limited -OBO at Cisco)
The TSUrl* functions are grabbing the URL itself from an MBuf/IOBuf, but my goal is to download the contents of that URL into a char*. I think I’m pretty close at this point as I have the downloaded response body in a IOBuffer, but can't figure how to copy that IOBuf into a char*. TSIOBufferR

Re: Fetching URL contents in a plugin

2019-06-21 Thread Alan Carroll
There's TSUrlStringGet(), which unfortunately returns an allocated buffer. Internally there is url_string_get_buff but it's apparently not accessible from the C API. I should fix that. On Fri, Jun 21, 2019 at 11:21 AM Alan Carroll < solidwallofc...@verizonmedia.com> wrote: > Does TSUrlPrint not w

Re: Fetching URL contents in a plugin

2019-06-21 Thread Alan Carroll
Does TSUrlPrint not work for you? If you set up the TSIOBuffer to have a large block size (say >= 128K) it should fit in a single block. We also might want to push on adding TSIOBufferReaderRead() which would make that easier as well. On Fri, Jun 21, 2019 at 11:11 AM Eric Friedrich -X (efriedri -

Re: Fetching URL contents in a plugin

2019-06-21 Thread Eric Friedrich -X (efriedri - TRITON UK BIDCO LIMITED c/o Alter Domus (UK) Limited -OBO at Cisco)
Yeah thats where I was looking to find the example. I’m basically cribbing the state machine from there with a few modifications. —Eric > On Jun 21, 2019, at 11:29 AM, Leif Hedstrom wrote: > > > >> On Jun 21, 2019, at 06:25, Eric Friedrich -X (efriedri - TRITON UK BIDCO >> LIMITED c/o Alte

Re: Fetching URL contents in a plugin

2019-06-21 Thread Leif Hedstrom
> On Jun 21, 2019, at 06:25, Eric Friedrich -X (efriedri - TRITON UK BIDCO > LIMITED c/o Alter Domus (UK) Limited -OBO at Cisco) > wrote: > > Thanks- > On receiving a request for an object (say at URL1), I’m trying to fetch a > different file (URL2) that contains some authorization data to

Re: Fetching URL contents in a plugin

2019-06-21 Thread Walt Karas
It's probably easier to use the CPP API: https://github.com/apache/trafficserver/blob/master/include/tscpp/api/InterceptPlugin.h But there are rumors of lower performance with the CPP API. On Fri, Jun 21, 2019 at 10:06 AM Walt Karas wrote: > Sounds like maybe you want an intercept plugin: > htt

Re: Fetching URL contents in a plugin

2019-06-21 Thread Walt Karas
Sounds like maybe you want an intercept plugin: https://docs.trafficserver.apache.org/en/8.0.x/developer-guide/plugins/hooks-and-transactions/intercepting-http-transactions.en.html

Re: Fetching URL contents in a plugin

2019-06-21 Thread Eric Friedrich -X (efriedri - TRITON UK BIDCO LIMITED c/o Alter Domus (UK) Limited -OBO at Cisco)
Thanks- On receiving a request for an object (say at URL1), I’m trying to fetch a different file (URL2) that contains some authorization data to determine if the original request should be allowed. My hope was to find a more compact way to build a new request, do a TSHttpConnect() and then r

Re: Fetching URL contents in a plugin

2019-06-20 Thread Shu Kit Chan
Hopefully this is of help. https://github.com/apache/trafficserver/pull/5639/files#diff-5c2f3297b2a6ac986fbf042017435a6a It illustrates an example of using the Lua script to get the content of a response into variable and print it out. Kit On Thu, Jun 20, 2019 at 5:41 PM Eric Friedrich -X (efri

Fetching URL contents in a plugin

2019-06-20 Thread Eric Friedrich -X (efriedri - TRITON UK BIDCO LIMITED c/o Alter Domus (UK) Limited -OBO at Cisco)
Is there a simple API call to use to fetch the contents of a URL into a buffer? I found an example of something close in the authproxy sample plugin, but there looks to be almost a hundred lines of rather boilerplate code. I’d like to avoid the copy and paste if I can —Eric