blob: c2640d11ecc5421ac36020f2569a73be0c9cd4c8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
package XXV::OUTPUT::HTML::PUSH;
use strict;
use Tools;
$| = 1;
=head1 NAME
XXV::OUTPUT::HTML::PUSH - A Push for http system
=head1 SYNOPSIS
use XXV::OUTPUT::HTML::PUSH;
my $pusher = XXV::OUTPUT::HTML::PUSH->new(
-cgi => $self->{cgi}, # The CGI Object from Lincoln Stein
-handle => $self->{handle}, # The handle to printout the http Stuff
);
$pusher->start(); # Start the Push Process
while($c > 10) {
$pusher->print($c++); # Print out the message
}
$pusher->stop(); # Stop the Push
=cut
# ------------------
sub new {
# ------------------
my($class, %attr) = @_;
my $self = {};
bless($self, $class);
$self->{handle} = $attr{'-handle'}
|| return error('No handle defined!');
$self->{cgi} = $attr{'-cgi'}
|| return error('No CGI Object defined!');
$self->{charset} = $attr{'-charset'}
|| 'ISO-8859-1';
return $self;
}
# ------------------
sub start {
# ------------------
my $self = shift || return error('No object defined!');
my $out = shift || 0;
$self->{handle}->print($self->{cgi}->multipart_init(-boundary=>'----here we go!'));
$self->print($out) if($out);
}
# ------------------
sub print {
# ------------------
my $self = shift || return error('No object defined!');
my $msg = shift || return;
my $type = shift || 'text/html';
$self->{handle}->print($self->{cgi}->multipart_start(-type=>$type));
$self->{handle}->print($msg."\n");
$self->{handle}->print($self->{cgi}->multipart_end);
}
# ------------------
sub follow_print {
# ------------------
my $self = shift || return error('No object defined!');
my $msg = shift || return;
my $type = shift || 'text/html';
unless($self->{header}) {
$self->{handle}->print($self->{cgi}->multipart_start(-type=>$type));
$self->{header} = 1;
}
$self->{handle}->print($msg."\n");
}
# ------------------
sub stop {
# ------------------
my $self = shift || return error('No object defined!');
$self->{handle}->print($self->{cgi}->multipart_end);
$self->{handle}->print($self->{cgi}->header(
-type => 'text/html',
-status => "200 OK",
-charset => $self->{charset},
));
}
1;
|