trouble creating a blank SOAPAction

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

trouble creating a blank SOAPAction

Greg Hemphill
Hi,

I'm a little stuck trying to make a soap call to a 3rd party.  The API  
I'm working with requires an empty SOAPAction param to be supplied in  
the head of the request.  However the include_URL tag doesn't appear  
to supply a SOAPAction if the value is blank.  See examples below.


Test 1:

$Test1 =
        Include_URL( $Host '/test/SoapTest/' ,
                // -PostParams = $SOAP_Envelope,
                -SendMIMEHEaders = Array( 'content-type'='text/xml', 'SOAPAction' =  
'' )
        );


Test 2:

$Test2 =
        Include_URL( $Host '/test/SoapTest/' ,
                // -PostParams = $SOAP_Envelope,
                -SendMIMEHEaders = Array( 'content-type'='text/xml', 'SOAPAction' =  
'blah' )
        );


Headers for Test 1:

Accept: */*
content-type: text/xml
Host: webstop.com
Pragma: no-cache


Headers for Test 2:

Accept: */*
content-type: text/xml
Host: webstop.com
Pragma: no-cache
SOAPAction: blah


What I need:

Accept: */*
content-type: text/xml
Host: webstop.com
Pragma: no-cache
SOAPAction:

Any ideas how I can get the include_url tag to supply a blank  
SOAPAction?  Should I be using something other than include_url for  
this?

Thanks,
Greg Hemphill

--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: trouble creating a blank SOAPAction

decorior
What happens if you pass a space?

generally I trim everything I get passed, and maybe these guys do too!

On Mar 25, 2009, at 2:25 PM, Greg Hemphill wrote:

> Hi,
>
> I'm a little stuck trying to make a soap call to a 3rd party.  The  
> API I'm working with requires an empty SOAPAction param to be  
> supplied in the head of the request.  However the include_URL tag  
> doesn't appear to supply a SOAPAction if the value is blank.  See  
> examples below.
>
>
> Test 1:
>
> $Test1 =
> Include_URL( $Host '/test/SoapTest/' ,
> // -PostParams = $SOAP_Envelope,
> -SendMIMEHEaders = Array( 'content-type'='text/xml', 'SOAPAction'  
> = '' )
> );
>
>
> Test 2:
>
> $Test2 =
> Include_URL( $Host '/test/SoapTest/' ,
> // -PostParams = $SOAP_Envelope,
> -SendMIMEHEaders = Array( 'content-type'='text/xml', 'SOAPAction'  
> = 'blah' )
> );
>
>
> Headers for Test 1:
>
> Accept: */*
> content-type: text/xml
> Host: webstop.com
> Pragma: no-cache
>
>
> Headers for Test 2:
>
> Accept: */*
> content-type: text/xml
> Host: webstop.com
> Pragma: no-cache
> SOAPAction: blah
>
>
> What I need:
>
> Accept: */*
> content-type: text/xml
> Host: webstop.com
> Pragma: no-cache
> SOAPAction:
>
> Any ideas how I can get the include_url tag to supply a blank  
> SOAPAction?  Should I be using something other than include_url for  
> this?
>
> Thanks,
> Greg Hemphill
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: trouble creating a blank SOAPAction

Greg Hemphill
Tried that... a space has the same result as a blank value (not added  
to the header).  I also tried putting something bogus in there like  
'blah' or just the domain name... but it throws an error on their  
end.  I might be able to get them to modify their code to accept a  
bogus value... but that feels like an ugly hack.

Greg

On Mar 25, 2009, at 4:33 PM, Deco Rior wrote:

> What happens if you pass a space?
>
> generally I trim everything I get passed, and maybe these guys do too!
>
> On Mar 25, 2009, at 2:25 PM, Greg Hemphill wrote:
>
>> Hi,
>>
>> I'm a little stuck trying to make a soap call to a 3rd party.  The  
>> API I'm working with requires an empty SOAPAction param to be  
>> supplied in the head of the request.  However the include_URL tag  
>> doesn't appear to supply a SOAPAction if the value is blank.  See  
>> examples below.
>>
>>
>> Test 1:
>>
>> $Test1 =
>> Include_URL( $Host '/test/SoapTest/' ,
>> // -PostParams = $SOAP_Envelope,
>> -SendMIMEHEaders = Array( 'content-type'='text/xml', 'SOAPAction'  
>> = '' )
>> );
>>
>>
>> Test 2:
>>
>> $Test2 =
>> Include_URL( $Host '/test/SoapTest/' ,
>> // -PostParams = $SOAP_Envelope,
>> -SendMIMEHEaders = Array( 'content-type'='text/xml', 'SOAPAction'  
>> = 'blah' )
>> );
>>
>>
>> Headers for Test 1:
>>
>> Accept: */*
>> content-type: text/xml
>> Host: webstop.com
>> Pragma: no-cache
>>
>>
>> Headers for Test 2:
>>
>> Accept: */*
>> content-type: text/xml
>> Host: webstop.com
>> Pragma: no-cache
>> SOAPAction: blah
>>
>>
>> What I need:
>>
>> Accept: */*
>> content-type: text/xml
>> Host: webstop.com
>> Pragma: no-cache
>> SOAPAction:
>>
>> Any ideas how I can get the include_url tag to supply a blank  
>> SOAPAction?  Should I be using something other than include_url for  
>> this?
>>
>> Thanks,
>> Greg Hemphill
>>
>> --
>> This list is a free service of LassoSoft: http://www.LassoSoft.com/
>> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
>> Manage your subscription: http://www.ListSearch.com/Lasso/
>>
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: trouble creating a blank SOAPAction

Bil Corry-3
In reply to this post by decorior
Deco Rior wrote on 3/25/2009 3:33 PM:
> What happens if you pass a space?
>
> generally I trim everything I get passed, and maybe these guys do too!

It appears Lasso actually trims the value before it gets sent and if it is of size 0, it tosses out the header entirely.  You'll have to feature request that Lasso actually use all the headers it is given.

In the meanwhile, since the source isn't available, you'll either have to use curl on the command line, or roll your own include_url use the [net] tags.  I actually have a version I wrote back in 2004 when the built-in include_url wasn't working properly.  It's below, not sure if it'll run under Lasso 8.5, not sure it won't exhibit the same behavior as Lasso, but who knows, maybe it'll work or can work with a little effort.

- Bil


<?lassoscript
//[
        define_tag:
                'lw_hexToDec',
                -priority='replace',
                -required='base16_string';
               
                // (c) Bil Corry
                // usage: {hexToDec:'2B2B'} should output '11051'
       
                // init base10
                local:'base10'= integer;
               
                // init valid hex chars, 0 is redundent for how we use this list, so it doesn't appear
                local:'hex_list'='123456789ABCDEF';
               
                // get the length of the base16 string
                local:'base16_len'=#base16_string->length;
       
                // work from back to front (rightmost digit to leftmost)
                loop: -loopfrom=#base16_len,-loopto=1,-loopincrement=(-1);
                        #base10 += ((#hex_list->(find: (#base16_string->(get:loop_count)))) * (math_pow: 16, #base16_len - loop_count));
                /loop;
       
                // return base10 number
                return: (integer: #base10);
        /define_tag;

        define_tag:
                'include_url',
                -priority='replace',
                -required='url_in',
                -optional='RetrieveMIMEHeaders',
                -optional='SendMIMEHeaders',
                -optional='GETParams',
                -optional='POSTParams',
                -optional='Referrer',
                -optional='Referer',
                -optional='Username',
                -optional='Password';
               
                // lw_include_url
                // (c) bil corry

                local:'include_url_contents' = null;
               
                // -nodata
                local:'nodata' = false;
                if: params->(find:'-nodata')->size > 0;
                        local:'nodata' = true;
                /if;
               
                // -RetrieveMIMEHeaders
                if: !local_defined:'RetrieveMIMEHeaders';
                        local:'RetrieveMIMEHeaders' = null;
                /if;

                // -Referrer or -Referer
                if: !local_defined:'Referrer';
                        if: local_defined:'Referer';
                                local:'Referrer' = #Referer;
                        else;
                                local:'Referrer' = null;
                        /if;
                /if;

                // -Username
                if: !local_defined:'username';
                        local:'username' = null;
                /if;

                // -Password
                if: !local_defined:'password';
                        local:'password' = null;
                /if;

                // parse URL
                        local:'url' = #url_in;
                        local:'prefix' = 'http://';
                        local:'host' = null;
                        local:'port' = '80';
                        local:'path' = null;
                        local:'ssl' = false;
       
                        if: #url->(beginswith:'https://');
                                #prefix = 'https://';
                                #ssl = true;
                                #port = '443';
                                #url->(removeleading:'https://');
                        else: #url->(beginswith:'http://');
                                #url->(removeleading:'http://');
                        // else we assume we received 'www.example.com/somepage.lasso' as the url
                        /if;
       
                        local:'patharray' = #url->(split:'/');
                       
                        local:'hostport' = #patharray->(get:1)->(split:':');
                        #host = #hostport->(get:1);
                        if: #hostport->size == 2;
                                #port = #hostport->(get:2);
                        /if;
                       
                        #patharray->(remove:1);
                        #path = #patharray->(join:'/');
                        #path = '/' + #path;
                        //return: 'host=' #host ' port=' #port ' path=' #path 'ssl=' #ssl;


                // -GETParams
                        local:'params' = string;
                        if: local_defined:'getparams';
                                if: #getparams->type == 'array';
                                        iterate: #getparams, local:'param';
                                                if: #param->type == 'pair';
                                                        #params += '&' + (encode_stricturl: #param->name) + '=' + (encode_stricturl: #param->value);
                                                /if;
                                        /iterate;
                                /if;
                                if: #params->size;
                                        if: #path !>> '?';
                                                #params->(removeleading:'&');
                                                #path += '?' + #params;
                                        else;
                                                #path += #params;
                                        /if;
                                /if;
                        /if;


                // -POSTParams
                        local:'post' = string;
                        if: local_defined:'postparams';
                                if: #postparams->type == 'array';
                                        iterate: #postparams, local:'param';
                                                if: #param->type == 'pair';
                                                        #post += '&' + (encode_stricturl: #param->name) + '=' + (encode_stricturl: #param->value);
                                                /if;
                                        /iterate;
                                else: #postparams->type == 'string';
                                        #post = #postparams;
                                /if;
                                if: #post->size;
                                        #post->(removeleading:'&');
                                /if;
                        /if;


                // -SendMIMEHeaders
                       
                        // setup default headers
                        local:'sendmimeheaders_base' = (map: 'Host' = #host + ':' + #port, 'User-Agent' = 'Lasso Professional ' + (lasso_version: -lassoversion));
                        if: #referrer != null;
                                #sendmimeheaders_base->(insert: 'Referer' = #referrer);
                        /if;
                        if: #username != null;
                                #sendmimeheaders_base->(insert: 'Authorization' = 'basic ' + (encode_base64: #username + ':' + #password));
                        /if;

                        // add/override any others
                        if: !local_defined:'sendmimeheaders';
                                local:'sendmimeheaders' = #sendmimeheaders_base;
                        else;
                                if: #sendmimeheaders->type == 'array';
                                        iterate: #sendmimeheaders,local:'header';
                                                if: #header->type == 'pair';
                                                        #sendmimeheaders_base->(insert: #header->name = #header->value);
                                                /if;
                                        /iterate;
                                /if;
                        /if;
                        #sendmimeheaders = #sendmimeheaders_base;



                // connect and retrieve
                       
                        local:'connection' = net;
                       
                        #connection->(setblocking: false);
                       
                        handle; // make sure it gets closed
                                #connection->close;
                        /handle;
                       
                        if: #ssl;
                                #connection->(settype: Net_TypeSSL);
                        /if;

                        local:'result' = null;
                       
                        #result = #connection->(connect: #host, #port);
                        fail_if: (#result != Net_ConnectOK) && (#result != Net_ConnectInProgress), (-1), 'TCP Connect Error: ' + #result;

                        #result = #connection->(wait: 30, Net_WaitWrite);
                        fail_if: #result == Net_WaitTimeOut, (-2), 'TCP Write Timeout: ' + #result;
                       
                        local:'write' = string;
                        if: #post->size;
                                #write += 'POST '+ #path +' HTTP/1.1\r\n';
                                #write += 'Content-Type: application/x-www-form-urlencoded\r\n';
                                #write += 'Content-Length: ' + #post->size + '\r\n';
                        else;
                                #write += 'GET '+ #path +' HTTP/1.1\r\n';
                        /if;
                       
                        iterate: #sendMIMEHeaders, local:'header';
                                        #write += #header->name + ': ' + #header->value + '\r\n';
                        /iterate;
                       
                        #write += '\r\n';
                       
                        if: #post->size; // post body
                                #write += #post + '\r\n';
                        /if;

                        #write += '\r\n';
                       
                        //return: #write;
                               
                        #result = #connection->(write: #write);
                        fail_if: #result == 0, (-3), 'TCP Write Error: ' + #result;
                       
                        // stop here if -nodata
                        if: #nodata;
                                #connection->close;
                                return: null;
                        /if;

                        local:'more_to_read' = true;
                        while: #more_to_read;
                                #result = #connection->(wait: 10, Net_WaitRead);
                                if: #result == Net_WaitTimeOut;
                                        #more_to_read = false;
                                else;
                                        protect;
                                                handle: error_currenterror != error_noerror;
                                                        #more_to_read = false;
                                                /handle;
                                                #include_url_contents += #connection->(read: 65536);
                                        /protect;
                                /if;
                        /while;

                        #connection->close;

                // parse headers
                        local:'headers' = #include_url_contents->(split:'\r\n\r\n');
                        if: #headers->size > 1;
                                #headers = #headers->(get:1);
                        /if;
                        #include_url_contents->(removeleading: #headers + '\r\n\r\n');

                // build header array
                        local:'headerarray' = array;
                        local:'headersplit' = null;
                        #headers = #headers->(split:'\r\n');
                        iterate: #headers, local:'header';
                                #headersplit = #header->(split:': ');
                                if: #headersplit->size > 1;
                                        #headerarray->(insert: #headersplit->(get:1) =  #headersplit->(get:2));
                                /if;
                        /iterate;
               
                // page retrieved in "chunked" encoding?
                        if: (string: #headerarray) >> '(Transfer-Encoding)=(chunked)';
                                // decode "chunked" encoding
                               
                                local:'more_chunks' = true;
                                local:'chunksize' = integer;
                                local:'chunks' = #include_url_contents;
                                #include_url_contents = string;  // reset
                                local:'chunkline' = #chunks->(split:'\r\n')->(get:1);

                                while: #more_chunks;
                                        local:'chunksize' = (lw_hextodec: #chunkline->(split:';')->(get:1));
                                        #chunks->(remove: 1, #chunkline->size + 2); // remove chunk line + \r\n
                                        if: #chunksize;
                                                #include_url_contents += #chunks->(substring: 1, #chunksize);
                                                #chunks->(remove: 1, #chunksize + 2); // remove content + \r\n
                                                #chunkline = #chunks->(split:'\r\n')->(get:1);
                                        else;
                                                #more_chunks = false;
                                        /if;
                                /while;

                                // parse optional chunked footer and add to header
                                        #headers = #chunks->(split:'\r\n');
                                        iterate: #headers, local:'header';
                                                #headersplit = #header->(split:': ');
                                                if: #headersplit->size > 1;
                                                        #headerarray->(insert: #headersplit->(get:1) =  #headersplit->(get:2));
                                                /if;
                                        /iterate;

                        /if;


                // -RetrieveMIMEHeaders
                        if: #RetrieveMIMEHeaders != null;
                                var: #RetrieveMIMEHeaders = #headerarray;

                        /if;


                // return
                        return: #include_url_contents;
        /define_tag;
//]
?>




--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/


Reply | Threaded
Open this post in threaded view
|

Re: trouble creating a blank SOAPAction

Greg Hemphill
Bill,

Thanks, I'll take a look at that tag.

Greg

On Mar 25, 2009, at 4:52 PM, Bil Corry wrote:

> Deco Rior wrote on 3/25/2009 3:33 PM:
>> What happens if you pass a space?
>>
>> generally I trim everything I get passed, and maybe these guys do  
>> too!
>
> It appears Lasso actually trims the value before it gets sent and if  
> it is of size 0, it tosses out the header entirely.  You'll have to  
> feature request that Lasso actually use all the headers it is given.
>
> In the meanwhile, since the source isn't available, you'll either  
> have to use curl on the command line, or roll your own include_url  
> use the [net] tags.  I actually have a version I wrote back in 2004  
> when the built-in include_url wasn't working properly.  It's below,  
> not sure if it'll run under Lasso 8.5, not sure it won't exhibit the  
> same behavior as Lasso, but who knows, maybe it'll work or can work  
> with a little effort.
>
> - Bil
>
>
> <?lassoscript
> //[
> define_tag:
> 'lw_hexToDec',
> -priority='replace',
> -required='base16_string';
>
> // (c) Bil Corry
> // usage: {hexToDec:'2B2B'} should output '11051'
>
> // init base10
> local:'base10'= integer;
>
> // init valid hex chars, 0 is redundent for how we use this list,  
> so it doesn't appear
> local:'hex_list'='123456789ABCDEF';
>
> // get the length of the base16 string
> local:'base16_len'=#base16_string->length;
>
> // work from back to front (rightmost digit to leftmost)
> loop: -loopfrom=#base16_len,-loopto=1,-loopincrement=(-1);
> #base10 += ((#hex_list->(find: (#base16_string-
> >(get:loop_count)))) * (math_pow: 16, #base16_len - loop_count));
> /loop;
>
> // return base10 number
> return: (integer: #base10);
> /define_tag;
>
> define_tag:
> 'include_url',
> -priority='replace',
> -required='url_in',
> -optional='RetrieveMIMEHeaders',
> -optional='SendMIMEHeaders',
> -optional='GETParams',
> -optional='POSTParams',
> -optional='Referrer',
> -optional='Referer',
> -optional='Username',
> -optional='Password';
>
> // lw_include_url
> // (c) bil corry
>
> local:'include_url_contents' = null;
>
> // -nodata
> local:'nodata' = false;
> if: params->(find:'-nodata')->size > 0;
> local:'nodata' = true;
> /if;
>
> // -RetrieveMIMEHeaders
> if: !local_defined:'RetrieveMIMEHeaders';
> local:'RetrieveMIMEHeaders' = null;
> /if;
>
> // -Referrer or -Referer
> if: !local_defined:'Referrer';
> if: local_defined:'Referer';
> local:'Referrer' = #Referer;
> else;
> local:'Referrer' = null;
> /if;
> /if;
>
> // -Username
> if: !local_defined:'username';
> local:'username' = null;
> /if;
>
> // -Password
> if: !local_defined:'password';
> local:'password' = null;
> /if;
>
> // parse URL
> local:'url' = #url_in;
> local:'prefix' = 'http://';
> local:'host' = null;
> local:'port' = '80';
> local:'path' = null;
> local:'ssl' = false;
>
> if: #url->(beginswith:'https://');
> #prefix = 'https://';
> #ssl = true;
> #port = '443';
> #url->(removeleading:'https://');
> else: #url->(beginswith:'http://');
> #url->(removeleading:'http://');
> // else we assume we received 'www.example.com/somepage.lasso' as  
> the url
> /if;
>
> local:'patharray' = #url->(split:'/');
>
> local:'hostport' = #patharray->(get:1)->(split:':');
> #host = #hostport->(get:1);
> if: #hostport->size == 2;
> #port = #hostport->(get:2);
> /if;
>
> #patharray->(remove:1);
> #path = #patharray->(join:'/');
> #path = '/' + #path;
> //return: 'host=' #host ' port=' #port ' path=' #path 'ssl=' #ssl;
>
>
> // -GETParams
> local:'params' = string;
> if: local_defined:'getparams';
> if: #getparams->type == 'array';
> iterate: #getparams, local:'param';
> if: #param->type == 'pair';
> #params += '&' + (encode_stricturl: #param->name) + '=' +  
> (encode_stricturl: #param->value);
> /if;
> /iterate;
> /if;
> if: #params->size;
> if: #path !>> '?';
> #params->(removeleading:'&');
> #path += '?' + #params;
> else;
> #path += #params;
> /if;
> /if;
> /if;
>
>
> // -POSTParams
> local:'post' = string;
> if: local_defined:'postparams';
> if: #postparams->type == 'array';
> iterate: #postparams, local:'param';
> if: #param->type == 'pair';
> #post += '&' + (encode_stricturl: #param->name) + '=' +  
> (encode_stricturl: #param->value);
> /if;
> /iterate;
> else: #postparams->type == 'string';
> #post = #postparams;
> /if;
> if: #post->size;
> #post->(removeleading:'&');
> /if;
> /if;
>
>
> // -SendMIMEHeaders
>
> // setup default headers
> local:'sendmimeheaders_base' = (map: 'Host' = #host + ':' +  
> #port, 'User-Agent' = 'Lasso Professional ' + (lasso_version: -
> lassoversion));
> if: #referrer != null;
> #sendmimeheaders_base->(insert: 'Referer' = #referrer);
> /if;
> if: #username != null;
> #sendmimeheaders_base->(insert: 'Authorization' = 'basic ' +  
> (encode_base64: #username + ':' + #password));
> /if;
>
> // add/override any others
> if: !local_defined:'sendmimeheaders';
> local:'sendmimeheaders' = #sendmimeheaders_base;
> else;
> if: #sendmimeheaders->type == 'array';
> iterate: #sendmimeheaders,local:'header';
> if: #header->type == 'pair';
> #sendmimeheaders_base->(insert: #header->name = #header-
> >value);
> /if;
> /iterate;
> /if;
> /if;
> #sendmimeheaders = #sendmimeheaders_base;
>
>
>
> // connect and retrieve
>
> local:'connection' = net;
>
> #connection->(setblocking: false);
>
> handle; // make sure it gets closed
> #connection->close;
> /handle;
>
> if: #ssl;
> #connection->(settype: Net_TypeSSL);
> /if;
>
> local:'result' = null;
>
> #result = #connection->(connect: #host, #port);
> fail_if: (#result != Net_ConnectOK) && (#result !=  
> Net_ConnectInProgress), (-1), 'TCP Connect Error: ' + #result;
>
> #result = #connection->(wait: 30, Net_WaitWrite);
> fail_if: #result == Net_WaitTimeOut, (-2), 'TCP Write Timeout: '  
> + #result;
>
> local:'write' = string;
> if: #post->size;
> #write += 'POST '+ #path +' HTTP/1.1\r\n';
> #write += 'Content-Type: application/x-www-form-urlencoded\r\n';
> #write += 'Content-Length: ' + #post->size + '\r\n';
> else;
> #write += 'GET '+ #path +' HTTP/1.1\r\n';
> /if;
>
> iterate: #sendMIMEHeaders, local:'header';
> #write += #header->name + ': ' + #header->value + '\r\n';
> /iterate;
>
> #write += '\r\n';
>
> if: #post->size; // post body
> #write += #post + '\r\n';
> /if;
>
> #write += '\r\n';
>
> //return: #write;
>
> #result = #connection->(write: #write);
> fail_if: #result == 0, (-3), 'TCP Write Error: ' + #result;
>
> // stop here if -nodata
> if: #nodata;
> #connection->close;
> return: null;
> /if;
>
> local:'more_to_read' = true;
> while: #more_to_read;
> #result = #connection->(wait: 10, Net_WaitRead);
> if: #result == Net_WaitTimeOut;
> #more_to_read = false;
> else;
> protect;
> handle: error_currenterror != error_noerror;
> #more_to_read = false;
> /handle;
> #include_url_contents += #connection->(read: 65536);
> /protect;
> /if;
> /while;
>
> #connection->close;
>
> // parse headers
> local:'headers' = #include_url_contents->(split:'\r\n\r\n');
> if: #headers->size > 1;
> #headers = #headers->(get:1);
> /if;
> #include_url_contents->(removeleading: #headers + '\r\n\r\n');
>
> // build header array
> local:'headerarray' = array;
> local:'headersplit' = null;
> #headers = #headers->(split:'\r\n');
> iterate: #headers, local:'header';
> #headersplit = #header->(split:': ');
> if: #headersplit->size > 1;
> #headerarray->(insert: #headersplit->(get:1) =  #headersplit-
> >(get:2));
> /if;
> /iterate;
>
> // page retrieved in "chunked" encoding?
> if: (string: #headerarray) >> '(Transfer-Encoding)=(chunked)';
> // decode "chunked" encoding
>
> local:'more_chunks' = true;
> local:'chunksize' = integer;
> local:'chunks' = #include_url_contents;
> #include_url_contents = string;  // reset
> local:'chunkline' = #chunks->(split:'\r\n')->(get:1);
>
> while: #more_chunks;
> local:'chunksize' = (lw_hextodec: #chunkline->(split:';')->(get:
> 1));
> #chunks->(remove: 1, #chunkline->size + 2); // remove chunk  
> line + \r\n
> if: #chunksize;
> #include_url_contents += #chunks->(substring: 1, #chunksize);
> #chunks->(remove: 1, #chunksize + 2); // remove content + \r\n
> #chunkline = #chunks->(split:'\r\n')->(get:1);
> else;
> #more_chunks = false;
> /if;
> /while;
>
> // parse optional chunked footer and add to header
> #headers = #chunks->(split:'\r\n');
> iterate: #headers, local:'header';
> #headersplit = #header->(split:': ');
> if: #headersplit->size > 1;
> #headerarray->(insert: #headersplit->(get:1) =  #headersplit-
> >(get:2));
> /if;
> /iterate;
>
> /if;
>
>
> // -RetrieveMIMEHeaders
> if: #RetrieveMIMEHeaders != null;
> var: #RetrieveMIMEHeaders = #headerarray;
>
> /if;
>
>
> // return
> return: #include_url_contents;
> /define_tag;
> //]
> ?>
>
>
>
>
> --
> This list is a free service of LassoSoft: http://www.LassoSoft.com/
> Search the list archives: http://www.ListSearch.com/Lasso/Browse/
> Manage your subscription: http://www.ListSearch.com/Lasso/
>
>


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/