include_url show HTTP response code in Lasso 8.6?

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

include_url show HTTP response code in Lasso 8.6?

stevepiercy
Is there any option in Lasso 8.6 include_url to retrieve the
HTTP response code?  -retrievemimeheaders does not include the
response code.

I know I could invoke curl via os_process via shell as a last
resort, but I'd like to avoid going that route.

I see in Lasso 9 there is a new -options parameter as well as
the curl type, but I'm stuck on 8.6 in this case.

--steve

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy              Website Builder              Soquel, CA
<[hidden email]>               <http://www.StevePiercy.com/>

#############################################################
Attend the Lasso Developer Conference 2014!
October 1-3, 2014 at Treefrog HQ, Newmarket, Ontario, Canada
http://www.lassosoft.com/LDC-newmarket-2014

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: include_url show HTTP response code in Lasso 8.6?

Bil Corry-3
I have a vague recollection that error_currenterror has it if it isn't 200, but could be wildly wrong.

- Bil

On Jul 1, 2014, at 4:07 AM, Steve Piercy - Website Builder <[hidden email]> wrote:

> Is there any option in Lasso 8.6 include_url to retrieve the HTTP response code?  -retrievemimeheaders does not include the response code.
>
> I know I could invoke curl via os_process via shell as a last resort, but I'd like to avoid going that route.
>
> I see in Lasso 9 there is a new -options parameter as well as the curl type, but I'm stuck on 8.6 in this case.
>
> --steve
>
> -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> Steve Piercy              Website Builder              Soquel, CA
> <[hidden email]>               <http://www.StevePiercy.com/>
>
> #############################################################
> Attend the Lasso Developer Conference 2014!
> October 1-3, 2014 at Treefrog HQ, Newmarket, Ontario, Canada
> http://www.lassosoft.com/LDC-newmarket-2014
>
> #############################################################
>
> This message is sent to you because you are subscribed to
> the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>
#############################################################
Attend the Lasso Developer Conference 2014!
October 1-3, 2014 at Treefrog HQ, Newmarket, Ontario, Canada
http://www.lassosoft.com/LDC-newmarket-2014

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: include_url show HTTP response code in Lasso 8.6?

stevepiercy
Dude.  You da man.

error_code returns the HTTP response code from include_url.

--steve


On 7/1/14 at 7:33 AM, [hidden email] (Bil Corry) pronounced:

> I have a vague recollection that error_currenterror has it if it isn't 200, but
> could be wildly wrong.
>
> - Bil
>
> On Jul 1, 2014, at 4:07 AM, Steve Piercy - Website Builder <[hidden email]>
> wrote:
>
> > Is there any option in Lasso 8.6 include_url to retrieve the HTTP response code?  
> -retrievemimeheaders does not include the response code.
> >
> > I know I could invoke curl via os_process via shell as a last resort, but I'd
> like to avoid going that route.
> >
> > I see in Lasso 9 there is a new -options parameter as well as the curl type, but
> I'm stuck on 8.6 in this case.
> >
> > --steve
> >
> > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> > Steve Piercy              Website Builder              Soquel, CA
> > <[hidden email]>               <http://www.StevePiercy.com/>
> >
> > #############################################################
> > Attend the Lasso Developer Conference 2014!
> > October 1-3, 2014 at Treefrog HQ, Newmarket, Ontario, Canada
> > http://www.lassosoft.com/LDC-newmarket-2014
> >
> > #############################################################
> >
> > This message is sent to you because you are subscribed to
> > the mailing list Lasso [hidden email]
> > Official list archives available at http://www.lassotalk.com
> > To unsubscribe, E-mail to: <[hidden email]>
> > Send administrative queries to  <[hidden email]>
> #############################################################
> Attend the Lasso Developer Conference 2014!
> October 1-3, 2014 at Treefrog HQ, Newmarket, Ontario, Canada
> http://www.lassosoft.com/LDC-newmarket-2014
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>   the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy              Website Builder              Soquel, CA
<[hidden email]>               <http://www.StevePiercy.com/>

#############################################################
Attend the Lasso Developer Conference 2014!
October 1-3, 2014 at Treefrog HQ, Newmarket, Ontario, Canada
http://www.lassosoft.com/LDC-newmarket-2014

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>
Reply | Threaded
Open this post in threaded view
|

Re: include_url show HTTP response code in Lasso 8.6?

French, Shelane
I wrote this tag. It does two things, I can get the title of the document
or the error code. It's probably not the most efficient, but it works:

<?LassoScript

//usage: extract_meta('http://myurl.com', -what='code');
//returns 200 (or other code)


define_tag('meta', -namespace='extract_', -required='url',
-optional='what');
        IF(local('what') == 'code');
                return(shell('curl -sLw "%{http_code}" ' #url ' -o /dev/null'));
        ELSE;
                local('content' = string(include_url(#url)));
                local('found_info' = map);
       
                local('tmp_content' = string);
       
                local('reg_cleanup' = regexp(-find = '\\s', -replace = ' '));
                local('reg_title' = regexp(-find = '<title>(.*)</title>', -ignorecase));
                local('reg_metas' = regexp(-find = '<meta(.*?)>', -ignorecase));
                local('reg_metaname' = regexp(-find = 'name( *?)=( *?)"(.*?)"',
-ignorecase));
                local('reg_metaequiv'= regexp(-find = 'http-equiv( *?)=( *?)"(.*?)"',
-ignorecase));
                local('reg_metacontent' = regexp(-find = 'content( *?)=( *?)"(.*?)"',
-ignorecase));
       
                #reg_cleanup->input(#content);
                #content = #reg_cleanup->replaceall;
                #reg_title->input(#content);
                #reg_metas->input(#content);
       
                #found_info->insert('title' = #reg_title->find ?
#reg_title->matchstring(1) | string);
               
                while(#reg_metas->find);
                        #tmp_content = #reg_metas->matchstring(1);
                        #reg_metaname->input(#tmp_content);
                        #reg_metaequiv->input(#tmp_content);
                        if(#reg_metaname->find);
                                #reg_metacontent->input(#tmp_content);
                                #found_info->insert(#reg_metaname->matchstring(3) =
#reg_metacontent->find ? #reg_metacontent->matchstring(3) | string);
                        else(#reg_metaequiv->find);
                                #reg_metacontent->input(#tmp_content);
                                #found_info->insert(#reg_metaequiv->matchstring(3) =
#reg_metacontent->find ? #reg_metacontent->matchstring(3) | string);
                        else;
                                #found_info->insert('meta_' + loop_count = #tmp_content);
                        /if;
                /while;
               
                if(local('what'));
                        return(#found_info->find(#what));
               
                else;
                        return(#found_info);
                /if;
        /IF;
       
/define_tag;
?>




On 6/30/14, 11:11 PM, "Steve Piercy - Website Builder"
<[hidden email]> wrote:

Dude.  You da man.

error_code returns the HTTP response code from include_url.

--steve


On 7/1/14 at 7:33 AM, [hidden email] (Bil Corry) pronounced:

> I have a vague recollection that error_currenterror has it if it isn't
>200, but
> could be wildly wrong.
>
> - Bil
>
> On Jul 1, 2014, at 4:07 AM, Steve Piercy - Website Builder
><[hidden email]>
> wrote:
>
> > Is there any option in Lasso 8.6 include_url to retrieve the HTTP
>response code?  
> -retrievemimeheaders does not include the response code.
> >
> > I know I could invoke curl via os_process via shell as a last resort,
>but I'd
> like to avoid going that route.
> >
> > I see in Lasso 9 there is a new -options parameter as well as the curl
>type, but
> I'm stuck on 8.6 in this case.
> >
> > --steve
> >
> > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
> > Steve Piercy              Website Builder              Soquel, CA
> > <[hidden email]>               <http://www.StevePiercy.com/>
> >
> > #############################################################
> > Attend the Lasso Developer Conference 2014!
> > October 1-3, 2014 at Treefrog HQ, Newmarket, Ontario, Canada
> > http://www.lassosoft.com/LDC-newmarket-2014
> >
> > #############################################################
> >
> > This message is sent to you because you are subscribed to
> > the mailing list Lasso [hidden email]
> > Official list archives available at http://www.lassotalk.com
> > To unsubscribe, E-mail to: <[hidden email]>
> > Send administrative queries to  <[hidden email]>
> #############################################################
> Attend the Lasso Developer Conference 2014!
> October 1-3, 2014 at Treefrog HQ, Newmarket, Ontario, Canada
> http://www.lassosoft.com/LDC-newmarket-2014
>
> #############################################################
>
> This message is sent to you because you are subscribed to
>   the mailing list Lasso [hidden email]
> Official list archives available at http://www.lassotalk.com
> To unsubscribe, E-mail to: <[hidden email]>
> Send administrative queries to  <[hidden email]>

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Steve Piercy              Website Builder              Soquel, CA
<[hidden email]>               <http://www.StevePiercy.com/>

#############################################################
Attend the Lasso Developer Conference 2014!
October 1-3, 2014 at Treefrog HQ, Newmarket, Ontario, Canada
http://www.lassosoft.com/LDC-newmarket-2014

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>

#############################################################
Attend the Lasso Developer Conference 2014!
October 1-3, 2014 at Treefrog HQ, Newmarket, Ontario, Canada
http://www.lassosoft.com/LDC-newmarket-2014

#############################################################

This message is sent to you because you are subscribed to
  the mailing list Lasso [hidden email]
Official list archives available at http://www.lassotalk.com
To unsubscribe, E-mail to: <[hidden email]>
Send administrative queries to  <[hidden email]>