[interchange-cvs] interchange - heins modified 4 files
interchange-core@icdevgroup.org
interchange-core@icdevgroup.org
Wed Aug 14 11:33:00 2002
User: heins
Date: 2002-08-14 15:32:04 GMT
Modified: lib/Vend Parse.pm Parser.pm Server.pm
Added: code/SystemTag deliver.coretag
Log:
* Add new [deliver ....] tag that allows you to deliver some content
without worrying about [tag op=3Dheader] and page spacing issues.
Adds new global variable $Vend::Sent which is authoritative notification
that all content is sent and that all further parsing of ITL
should stop.
Allows this:
[perl]
if($CGI->{foo}) {
# Oh, we need to send foo as text
$Tag->deliver( { type =3D> 'text/plain', body =3D> $Scratch->{foo} });
return;
}
else {
# Go about parsing ITL
}
[/perl]
Also will work with
[deliver type=3Dtext/plain][scratch foo][/deliver]
Revision Changes Path
1.1 interchange/code/SystemTag/deliver.coretag
rev 1.1, prev_rev 1.0
Index: deliver.coretag
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
UserTag deliver Order type
UserTag deliver HasEndTag
UserTag deliver addAttr
UserTag deliver Routine <<EOR
sub {
my ($type, $opt, $body) =3D @_;
my $out;
if($opt->{file}) {
$type ||=3D Vend::Util::mime_type($opt->{file});
return undef unless -f $opt->{file};
$out =3D \( readfile($opt->{file}) );
}
elsif(ref $body) {
$out =3D $body;
}
elsif($body) {
$out =3D \$body;
}
$type ||=3D 'application/octet-stream';
Vend::Tags->tag( { op =3D> 'header', name =3D> 'Content-Type', content =3D=
> $type } );
## This is a bounce, returns
if($opt->{location}) {
Vend::Tags->tag( { op =3D> 'header',
name =3D> 'Status',
content =3D> $opt->{status} || '302 moved',
} );
Vend::Tags->tag( { op =3D> 'header',
name =3D> 'Location',
content =3D> $opt->{location},
} );
$Vend::Sent =3D 1;
return 1;
}
=09
Vend::Tags->tag( { op =3D> 'header',
name =3D> 'Content-Type',
content =3D> $type,
} );
=09
if($opt->{extra_headers}) {
my @lines =3D grep /\S/, split /[\r\n]+/, $opt->{extra_headers};
for(@lines) {
my ($header, $val) =3D split /:/, $_;
Vend::Tags->tag( { op =3D> 'header',
name =3D> $header,
content =3D> $val,
} );
}
}
::response($out);
$Vend::Sent =3D 1;
return 1;
}
EOR
2.22 +2 -3 interchange/lib/Vend/Parse.pm
rev 2.22, prev_rev 2.21
Index: Parse.pm
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /var/cvs/interchange/lib/Vend/Parse.pm,v
retrieving revision 2.21
retrieving revision 2.22
diff -u -r2.21 -r2.22
--- Parse.pm 5 Aug 2002 06:04:49 -0000 2.21
+++ Parse.pm 14 Aug 2002 15:32:03 -0000 2.22
@@ -1,6 +1,6 @@
# Vend::Parse - Parse Interchange tags
#=20
-# $Id: Parse.pm,v 2.21 2002/08/05 06:04:49 mheins Exp $
+# $Id: Parse.pm,v 2.22 2002/08/14 15:32:03 mheins Exp $
#
# Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
#
@@ -35,7 +35,7 @@
=20
@ISA =3D qw(Exporter Vend::Parser);
=20
-$VERSION =3D substr(q$Revision: 2.21 $, 10);
+$VERSION =3D substr(q$Revision: 2.22 $, 10);
=20
@EXPORT =3D ();
@EXPORT_OK =3D qw(find_matching_end);
@@ -501,7 +501,6 @@
# syntax color '"
=20
sub start {
- return html_start(@_) if $_[0]->{HTML};
my($self, $tag, $attr, $attrseq, $origtext, $empty_container) =3D @_;
$tag =3D~ tr/-/_/; # canonical
$Vend::CurrentTag =3D $tag =3D lc $tag;
2.7 +8 -3 interchange/lib/Vend/Parser.pm
rev 2.7, prev_rev 2.6
Index: Parser.pm
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /var/cvs/interchange/lib/Vend/Parser.pm,v
retrieving revision 2.6
retrieving revision 2.7
diff -u -r2.6 -r2.7
--- Parser.pm 14 Jul 2002 03:35:03 -0000 2.6
+++ Parser.pm 14 Aug 2002 15:32:04 -0000 2.7
@@ -1,6 +1,6 @@
# Vend::Parser - Interchange parser class
#
-# $Id: Parser.pm,v 2.6 2002/07/14 03:35:03 jon Exp $
+# $Id: Parser.pm,v 2.7 2002/08/14 15:32:04 mheins Exp $
#
# Copyright (C) 1997-2002 Red Hat, Inc. <interchange@redhat.com>
#
@@ -66,7 +66,7 @@
=20
use HTML::Entities ();
use vars qw($VERSION);
-$VERSION =3D substr(q$Revision: 2.6 $, 10);
+$VERSION =3D substr(q$Revision: 2.7 $, 10);
=20
=20
sub new
@@ -99,7 +99,12 @@
# tokens from the beginning of $$buf until we can't deside whether
# it is a token or not, or the $$buf is empty.
while (1) { # the loop will end by returning when text is parsed
- # First we try to pull off any plain text (anything before a '[')
+ # If a preceding routine sent the response, stop=20
+ if ($Vend::Sent) {
+ $self->{OUT} =3D $self->{_buf} =3D '';
+ return $self;
+ }
+ # We try to pull off any plain text (anything before a '[')
if ($$buf =3D~ s/^([^[]+)// ) {
#my $eat =3D $1;
#::logDebug("plain eat=3D'$eat'");
2.11 +3 -2 interchange/lib/Vend/Server.pm
rev 2.11, prev_rev 2.10
Index: Server.pm
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /var/cvs/interchange/lib/Vend/Server.pm,v
retrieving revision 2.10
retrieving revision 2.11
diff -u -r2.10 -r2.11
--- Server.pm 11 Aug 2002 15:44:10 -0000 2.10
+++ Server.pm 14 Aug 2002 15:32:04 -0000 2.11
@@ -1,6 +1,6 @@
# Vend::Server - Listen for Interchange CGI requests as a background server
#
-# $Id: Server.pm,v 2.10 2002/08/11 15:44:10 mheins Exp $
+# $Id: Server.pm,v 2.11 2002/08/14 15:32:04 mheins Exp $
#
# Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
#
@@ -25,7 +25,7 @@
package Vend::Server;
=20
use vars qw($VERSION);
-$VERSION =3D substr(q$Revision: 2.10 $, 10);
+$VERSION =3D substr(q$Revision: 2.11 $, 10);
=20
use POSIX qw(setsid strftime);
use Vend::Util;
@@ -408,6 +408,7 @@
my ($s, $body) =3D @_;
#show_times("begin response send") if $Global::ShowTimes;
my $status;
+ return if $Vend::Sent;
if($Vend::StatusLine) {
$status =3D $Vend::StatusLine =3D~ /(?:^|\n)Status:\s+(.*)/i
? "$1"