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*.

 TSIOBufferReaderRead() looked like just the thing, but despite being in the 
7.x docs does not exist :-)
 TSIOBufferReaderCopy() also looked good, but is not exposed from the API. 

—Eric 

> On Jun 21, 2019, at 12:32 PM, Alan Carroll 
> <solidwallofc...@verizonmedia.com.INVALID> wrote:
> 
> 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 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 - TRITON UK
>> BIDCO LIMITED c/o Alter Domus (UK) Limited -OBO at Cisco)
>> <efrie...@cisco.com.invalid> wrote:
>> 
>>> 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 <zw...@apache.org> wrote:
>>>> 
>>>> 
>>>> 
>>>>> On Jun 21, 2019, at 06:25, Eric Friedrich -X (efriedri - TRITON UK
>>> BIDCO LIMITED c/o Alter Domus (UK) Limited -OBO at Cisco)
>>> <efrie...@cisco.com.invalid> 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
>>> 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 read the contents of URL2 into a buffer.
>>>> 
>>>> Sounds like the authproxy plugin. If it doesn’t have exactly what you
>>> need, it’s probably a good starting point.
>>>> 
>>>> — Leif
>>>>> 
>>>>> —Eric
>>>>> 
>>>>> 
>>>>> 
>>>>>> On Jun 21, 2019, at 1:05 AM, Shu Kit Chan <chanshu...@gmail.com>
>>> wrote:
>>>>>> 
>>>>>> 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 (efriedri - TRITON
>>>>>> UK BIDCO LIMITED c/o Alter Domus (UK) Limited -OBO at Cisco)
>>>>>> <efrie...@cisco.com.invalid> wrote:
>>>>>>> 
>>>>>>> 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
>>>>>>> 
>>>>> 
>>>> 
>>> 
>>> 

  • ... Eric Friedrich -X (efriedri - TRITON UK BIDCO LIMITED c/o Alter Domus (UK) Limited -OBO at Cisco)
    • ... Shu Kit Chan
      • ... Eric Friedrich -X (efriedri - TRITON UK BIDCO LIMITED c/o Alter Domus (UK) Limited -OBO at Cisco)
        • ... Leif Hedstrom
          • ... Eric Friedrich -X (efriedri - TRITON UK BIDCO LIMITED c/o Alter Domus (UK) Limited -OBO at Cisco)
            • ... Alan Carroll
              • ... Alan Carroll
                • ... Eric Friedrich -X (efriedri - TRITON UK BIDCO LIMITED c/o Alter Domus (UK) Limited -OBO at Cisco)
                • ... Alan Carroll
                • ... Alan Carroll
                • ... Alan Carroll
                • ... Aaron Canary
                • ... Eric Friedrich
      • ... Walt Karas
        • ... Walt Karas

Reply via email to