Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 |
2 | .\" | |
3 | .\" Standard preamble: | |
4 | .\" ======================================================================== | |
5 | .de Sh \" Subsection heading | |
6 | .br | |
7 | .if t .Sp | |
8 | .ne 5 | |
9 | .PP | |
10 | \fB\\$1\fR | |
11 | .PP | |
12 | .. | |
13 | .de Sp \" Vertical space (when we can't use .PP) | |
14 | .if t .sp .5v | |
15 | .if n .sp | |
16 | .. | |
17 | .de Vb \" Begin verbatim text | |
18 | .ft CW | |
19 | .nf | |
20 | .ne \\$1 | |
21 | .. | |
22 | .de Ve \" End verbatim text | |
23 | .ft R | |
24 | .fi | |
25 | .. | |
26 | .\" Set up some character translations and predefined strings. \*(-- will | |
27 | .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left | |
28 | .\" double quote, and \*(R" will give a right double quote. | will give a | |
29 | .\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to | |
30 | .\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C' | |
31 | .\" expand to `' in nroff, nothing in troff, for use with C<>. | |
32 | .tr \(*W-|\(bv\*(Tr | |
33 | .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' | |
34 | .ie n \{\ | |
35 | . ds -- \(*W- | |
36 | . ds PI pi | |
37 | . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch | |
38 | . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch | |
39 | . ds L" "" | |
40 | . ds R" "" | |
41 | . ds C` "" | |
42 | . ds C' "" | |
43 | 'br\} | |
44 | .el\{\ | |
45 | . ds -- \|\(em\| | |
46 | . ds PI \(*p | |
47 | . ds L" `` | |
48 | . ds R" '' | |
49 | 'br\} | |
50 | .\" | |
51 | .\" If the F register is turned on, we'll generate index entries on stderr for | |
52 | .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index | |
53 | .\" entries marked with X<> in POD. Of course, you'll have to process the | |
54 | .\" output yourself in some meaningful fashion. | |
55 | .if \nF \{\ | |
56 | . de IX | |
57 | . tm Index:\\$1\t\\n%\t"\\$2" | |
58 | .. | |
59 | . nr % 0 | |
60 | . rr F | |
61 | .\} | |
62 | .\" | |
63 | .\" For nroff, turn off justification. Always turn off hyphenation; it makes | |
64 | .\" way too many mistakes in technical documents. | |
65 | .hy 0 | |
66 | .if n .na | |
67 | .\" | |
68 | .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). | |
69 | .\" Fear. Run. Save yourself. No user-serviceable parts. | |
70 | . \" fudge factors for nroff and troff | |
71 | .if n \{\ | |
72 | . ds #H 0 | |
73 | . ds #V .8m | |
74 | . ds #F .3m | |
75 | . ds #[ \f1 | |
76 | . ds #] \fP | |
77 | .\} | |
78 | .if t \{\ | |
79 | . ds #H ((1u-(\\\\n(.fu%2u))*.13m) | |
80 | . ds #V .6m | |
81 | . ds #F 0 | |
82 | . ds #[ \& | |
83 | . ds #] \& | |
84 | .\} | |
85 | . \" simple accents for nroff and troff | |
86 | .if n \{\ | |
87 | . ds ' \& | |
88 | . ds ` \& | |
89 | . ds ^ \& | |
90 | . ds , \& | |
91 | . ds ~ ~ | |
92 | . ds / | |
93 | .\} | |
94 | .if t \{\ | |
95 | . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" | |
96 | . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' | |
97 | . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' | |
98 | . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' | |
99 | . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' | |
100 | . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' | |
101 | .\} | |
102 | . \" troff and (daisy-wheel) nroff accents | |
103 | .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' | |
104 | .ds 8 \h'\*(#H'\(*b\h'-\*(#H' | |
105 | .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] | |
106 | .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' | |
107 | .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' | |
108 | .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] | |
109 | .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] | |
110 | .ds ae a\h'-(\w'a'u*4/10)'e | |
111 | .ds Ae A\h'-(\w'A'u*4/10)'E | |
112 | . \" corrections for vroff | |
113 | .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' | |
114 | .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' | |
115 | . \" for low resolution devices (crt and lpr) | |
116 | .if \n(.H>23 .if \n(.V>19 \ | |
117 | \{\ | |
118 | . ds : e | |
119 | . ds 8 ss | |
120 | . ds o a | |
121 | . ds d- d\h'-1'\(ga | |
122 | . ds D- D\h'-1'\(hy | |
123 | . ds th \o'bp' | |
124 | . ds Th \o'LP' | |
125 | . ds ae ae | |
126 | . ds Ae AE | |
127 | .\} | |
128 | .rm #[ #] #H #V #F C | |
129 | .\" ======================================================================== | |
130 | .\" | |
131 | .IX Title "CGI::Push 3" | |
132 | .TH CGI::Push 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide" | |
133 | .SH "NAME" | |
134 | CGI::Push \- Simple Interface to Server Push | |
135 | .SH "SYNOPSIS" | |
136 | .IX Header "SYNOPSIS" | |
137 | .Vb 1 | |
138 | \& use CGI::Push qw(:standard); | |
139 | .Ve | |
140 | .PP | |
141 | .Vb 3 | |
142 | \& do_push(-next_page=>\e&next_page, | |
143 | \& -last_page=>\e&last_page, | |
144 | \& -delay=>0.5); | |
145 | .Ve | |
146 | .PP | |
147 | .Vb 8 | |
148 | \& sub next_page { | |
149 | \& my($q,$counter) = @_; | |
150 | \& return undef if $counter >= 10; | |
151 | \& return start_html('Test'), | |
152 | \& h1('Visible'),"\en", | |
153 | \& "This page has been called ", strong($counter)," times", | |
154 | \& end_html(); | |
155 | \& } | |
156 | .Ve | |
157 | .PP | |
158 | .Vb 7 | |
159 | \& sub last_page { | |
160 | \& my($q,$counter) = @_; | |
161 | \& return start_html('Done'), | |
162 | \& h1('Finished'), | |
163 | \& strong($counter - 1),' iterations.', | |
164 | \& end_html; | |
165 | \& } | |
166 | .Ve | |
167 | .SH "DESCRIPTION" | |
168 | .IX Header "DESCRIPTION" | |
169 | CGI::Push is a subclass of the \s-1CGI\s0 object created by \s-1CGI\s0.pm. It is | |
170 | specialized for server push operations, which allow you to create | |
171 | animated pages whose content changes at regular intervals. | |
172 | .PP | |
173 | You provide CGI::Push with a pointer to a subroutine that will draw | |
174 | one page. Every time your subroutine is called, it generates a new | |
175 | page. The contents of the page will be transmitted to the browser | |
176 | in such a way that it will replace what was there beforehand. The | |
177 | technique will work with \s-1HTML\s0 pages as well as with graphics files, | |
178 | allowing you to create animated GIFs. | |
179 | .PP | |
180 | Only Netscape Navigator supports server push. Internet Explorer | |
181 | browsers do not. | |
182 | .SH "USING CGI::Push" | |
183 | .IX Header "USING CGI::Push" | |
184 | CGI::Push adds one new method to the standard \s-1CGI\s0 suite, \fIdo_push()\fR. | |
185 | When you call this method, you pass it a reference to a subroutine | |
186 | that is responsible for drawing each new page, an interval delay, and | |
187 | an optional subroutine for drawing the last page. Other optional | |
188 | parameters include most of those recognized by the \s-1CGI\s0 \fIheader()\fR | |
189 | method. | |
190 | .PP | |
191 | You may call \fIdo_push()\fR in the object oriented manner or not, as you | |
192 | prefer: | |
193 | .PP | |
194 | .Vb 3 | |
195 | \& use CGI::Push; | |
196 | \& $q = new CGI::Push; | |
197 | \& $q->do_push(-next_page=>\e&draw_a_page); | |
198 | .Ve | |
199 | .PP | |
200 | .Vb 1 | |
201 | \& -or- | |
202 | .Ve | |
203 | .PP | |
204 | .Vb 2 | |
205 | \& use CGI::Push qw(:standard); | |
206 | \& do_push(-next_page=>\e&draw_a_page); | |
207 | .Ve | |
208 | .PP | |
209 | Parameters are as follows: | |
210 | .IP "\-next_page" 4 | |
211 | .IX Item "-next_page" | |
212 | .Vb 1 | |
213 | \& do_push(-next_page=>\e&my_draw_routine); | |
214 | .Ve | |
215 | .Sp | |
216 | This required parameter points to a reference to a subroutine responsible for | |
217 | drawing each new page. The subroutine should expect two parameters | |
218 | consisting of the \s-1CGI\s0 object and a counter indicating the number | |
219 | of times the subroutine has been called. It should return the | |
220 | contents of the page as an \fBarray\fR of one or more items to print. | |
221 | It can return a false value (or an empty array) in order to abort the | |
222 | redrawing loop and print out the final page (if any) | |
223 | .Sp | |
224 | .Vb 7 | |
225 | \& sub my_draw_routine { | |
226 | \& my($q,$counter) = @_; | |
227 | \& return undef if $counter > 100; | |
228 | \& return start_html('testing'), | |
229 | \& h1('testing'), | |
230 | \& "This page called $counter times"; | |
231 | \& } | |
232 | .Ve | |
233 | .Sp | |
234 | You are of course free to refer to create and use global variables | |
235 | within your draw routine in order to achieve special effects. | |
236 | .IP "\-last_page" 4 | |
237 | .IX Item "-last_page" | |
238 | This optional parameter points to a reference to the subroutine | |
239 | responsible for drawing the last page of the series. It is called | |
240 | after the \-next_page routine returns a false value. The subroutine | |
241 | itself should have exactly the same calling conventions as the | |
242 | \&\-next_page routine. | |
243 | .IP "\-type" 4 | |
244 | .IX Item "-type" | |
245 | This optional parameter indicates the content type of each page. It | |
246 | defaults to \*(L"text/html\*(R". Normally the module assumes that each page | |
247 | is of a homogenous \s-1MIME\s0 type. However if you provide either of the | |
248 | magic values \*(L"heterogeneous\*(R" or \*(L"dynamic\*(R" (the latter provided for the | |
249 | convenience of those who hate long parameter names), you can specify | |
250 | the \s-1MIME\s0 type \*(-- and other header fields \*(-- on a per-page basis. See | |
251 | \&\*(L"heterogeneous pages\*(R" for more details. | |
252 | .IP "\-delay" 4 | |
253 | .IX Item "-delay" | |
254 | This indicates the delay, in seconds, between frames. Smaller delays | |
255 | refresh the page faster. Fractional values are allowed. | |
256 | .Sp | |
257 | \&\fBIf not specified, \-delay will default to 1 second\fR | |
258 | .IP "\-cookie, \-target, \-expires, \-nph" 4 | |
259 | .IX Item "-cookie, -target, -expires, -nph" | |
260 | These have the same meaning as the like-named parameters in | |
261 | \&\fICGI::header()\fR. | |
262 | .Sp | |
263 | If not specified, \-nph will default to 1 (as needed for many servers, see below). | |
264 | .Sh "Heterogeneous Pages" | |
265 | .IX Subsection "Heterogeneous Pages" | |
266 | Ordinarily all pages displayed by CGI::Push share a common \s-1MIME\s0 type. | |
267 | However by providing a value of \*(L"heterogeneous\*(R" or \*(L"dynamic\*(R" in the | |
268 | \&\fIdo_push()\fR \-type parameter, you can specify the \s-1MIME\s0 type of each page | |
269 | on a case-by-case basis. | |
270 | .PP | |
271 | If you use this option, you will be responsible for producing the | |
272 | \&\s-1HTTP\s0 header for each page. Simply modify your draw routine to | |
273 | look like this: | |
274 | .PP | |
275 | .Vb 7 | |
276 | \& sub my_draw_routine { | |
277 | \& my($q,$counter) = @_; | |
278 | \& return header('text/html'), # note we're producing the header here | |
279 | \& start_html('testing'), | |
280 | \& h1('testing'), | |
281 | \& "This page called $counter times"; | |
282 | \& } | |
283 | .Ve | |
284 | .PP | |
285 | You can add any header fields that you like, but some (cookies and | |
286 | status fields included) may not be interpreted by the browser. One | |
287 | interesting effect is to display a series of pages, then, after the | |
288 | last page, to redirect the browser to a new \s-1URL\s0. Because \fIredirect()\fR | |
289 | does b<not> work, the easiest way is with a \-refresh header field, | |
290 | as shown below: | |
291 | .PP | |
292 | .Vb 8 | |
293 | \& sub my_draw_routine { | |
294 | \& my($q,$counter) = @_; | |
295 | \& return undef if $counter > 10; | |
296 | \& return header('text/html'), # note we're producing the header here | |
297 | \& start_html('testing'), | |
298 | \& h1('testing'), | |
299 | \& "This page called $counter times"; | |
300 | \& } | |
301 | .Ve | |
302 | .PP | |
303 | .Vb 9 | |
304 | \& sub my_last_page { | |
305 | \& return header(-refresh=>'5; URL=http://somewhere.else/finished.html', | |
306 | \& -type=>'text/html'), | |
307 | \& start_html('Moved'), | |
308 | \& h1('This is the last page'), | |
309 | \& 'Goodbye!' | |
310 | \& hr, | |
311 | \& end_html; | |
312 | \& } | |
313 | .Ve | |
314 | .Sh "Changing the Page Delay on the Fly" | |
315 | .IX Subsection "Changing the Page Delay on the Fly" | |
316 | If you would like to control the delay between pages on a page-by-page | |
317 | basis, call \fIpush_delay()\fR from within your draw routine. \fIpush_delay()\fR | |
318 | takes a single numeric argument representing the number of seconds you | |
319 | wish to delay after the current page is displayed and before | |
320 | displaying the next one. The delay may be fractional. Without | |
321 | parameters, \fIpush_delay()\fR just returns the current delay. | |
322 | .SH "INSTALLING CGI::Push SCRIPTS" | |
323 | .IX Header "INSTALLING CGI::Push SCRIPTS" | |
324 | Server push scripts must be installed as no-parsed-header (\s-1NPH\s0) | |
325 | scripts in order to work correctly on many servers. On Unix systems, | |
326 | this is most often accomplished by prefixing the script's name with \*(L"nph\-\*(R". | |
327 | Recognition of \s-1NPH\s0 scripts happens automatically with WebSTAR and | |
328 | Microsoft \s-1IIS\s0. Users of other servers should see their documentation | |
329 | for help. | |
330 | .PP | |
331 | Apache web server from version 1.3b2 on does not need server | |
332 | push scripts installed as \s-1NPH\s0 scripts: the \-nph parameter to \fIdo_push()\fR | |
333 | may be set to a false value to disable the extra headers needed by an | |
334 | \&\s-1NPH\s0 script. | |
335 | .SH "AUTHOR INFORMATION" | |
336 | .IX Header "AUTHOR INFORMATION" | |
337 | Copyright 1995\-1998, Lincoln D. Stein. All rights reserved. | |
338 | .PP | |
339 | This library is free software; you can redistribute it and/or modify | |
340 | it under the same terms as Perl itself. | |
341 | .PP | |
342 | Address bug reports and comments to: lstein@cshl.org | |
343 | .SH "BUGS" | |
344 | .IX Header "BUGS" | |
345 | This section intentionally left blank. | |
346 | .SH "SEE ALSO" | |
347 | .IX Header "SEE ALSO" | |
348 | CGI::Carp, \s-1CGI\s0 |