[ic] posttourl.tag

Kevin Walsh kevin at cursor.biz
Thu Aug 28 03:43:57 EDT 2003


Grant [listbox at email.com] wrote:
> 
> Marc posted the posttourl.tag on the list for me.  I modified it and
> subsequently couldn't get IC to restart without complaining about the tag.
> I then tried to use the tag just how it was posted and I get a different
> error at restart:
> 
> 
> Calling UI...Warning while compiling UserTag 'posttourl':
> 
>         Useless use of a constant in void context at (eval 74) line 18,
> <SYSTAG> line 26.
> 
> Useless use of a constant in void context at (eval 74) line 19, <SYSTAG>
> line 26.
> 
> Useless use of a constant in void context at (eval 74) line 20, <SYSTAG>
> line 26.
> 
> In line 26 of the configuration file
> '/store/ic493/code/UserTag/posttourl.tag':
> 
> 
> I'm stumped since I get this error with an unmodified tag.  Can anyone else
> restart with the tag without any errors?  Here's the tag:
> 
> 
> Usertag posttourl Order url params
> Usertag posttourl Interpolate 1
> Usertag posttourl Routine <<EOR
> sub {
> require HTTP::Request;
> require HTTP::Headers;
> require LWP::UserAgent; # SSL cabable if Crypt::SSLeay installed
>         my $url=shift; my $params=shift;
>         $ENV{'HTTPS_VERSION'} = '3';
>         $ENV{'HTTPS_CERT_FILE'}='xxx.pem';
>         $ENV{'HTTPS_KEY_FILE'}='xxx.key';
> 
>         my $page="";
>         my $request=new HTTP::Request 'POST' => $url;
>         $request->content_type('application/x-www-form-urlencoded');
>         $request->content($params);
>         $request->content_length(length($params));
> 
>         my $ua=LWP::UserAgent->new;
>         my $response = $ua->request($request);
>         $page.=$response->as_string,"\n\n\n";
>         $page.=$response->code,"\n";
>         $page.=$response->message,"\n";
>         return $page;
> }
> EOR
> 
You're using a comma (,) where you should be using a dot (.) on the
three "$page .=" lines, at the end of the sub.

Here's a slightly cleaner (although untested) version:

    Usertag posttourl Order url params
    Usertag posttourl Routine <<EOR
    use HTTP::Request;
    use HTTP::Headers;
    use LWP::UserAgent;
    sub {
        my ($url,$params) = @_;

        local($ENV{'HTTPS_VERSION'}) = '3';
        local($ENV{'HTTPS_CERT_FILE'}) = 'xxx.pem';
        local($ENV{'HTTPS_KEY_FILE'}) = 'xxx.key';

        my $request = new HTTP::Request('POST' => $url);
        $request->content_type('application/x-www-form-urlencoded');
        $request->content($params);
        $request->content_length(length($params));

        my $ua = new LWP::UserAgent;
        my $response = $ua->request($request);

        my $page = $response->as_string() . "\n\n\n";
        $page .= $response->code() . "\n";
        $page .= $response->message() . "\n";

        return $page;
    }
    EOR

-- 
   _/   _/  _/_/_/_/  _/    _/  _/_/_/  _/    _/
  _/_/_/   _/_/      _/    _/    _/    _/_/  _/   K e v i n   W a l s h
 _/ _/    _/          _/ _/     _/    _/  _/_/    kevin at cursor.biz
_/   _/  _/_/_/_/      _/    _/_/_/  _/    _/



More information about the interchange-users mailing list