Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improve documentation for -status

    (And apparently some other changes which I thought I had already commited.)
  • Loading branch information...
commit 3f960055ea61143b1cfc67de8f3a65cc5c8719d5 1 parent 257fa53
@markstos authored
Showing with 27 additions and 13 deletions.
  1. +6 −0 Changes
  2. +1 −0  MANIFEST
  3. +6 −2 lib/CGI.pm
  4. +14 −11 t/url.t
View
6 Changes
@@ -1,5 +1,11 @@
+ [DOCUMENTATION]
+ - Clarify that when -status is used, the human-readable phase should be included, per RFC 2616.
+ Thanks to SREZIC@cpan.org (RT#76691).
+
[INTERNALS]
- More tests for header(), thanks to Ryo Anazawa.
+ - t/url.t has been fixed on VMS. Thanks to cberry@cpan.org (RT#72380)
+ - MANIFEST patched so that t/multipart_init.t is included again. Thanks to shay@cpan.org (RT#76189)
Version 3.59 Dec 29th, 2011
View
1  MANIFEST
@@ -54,6 +54,7 @@ t/html.t
t/http.t
t/init.t
t/init_test.txt
+t/multipart_init.t
t/no_tabindex.t
t/param_fetch.t
t/popup_menu.t
View
8 lib/CGI.pm
@@ -5184,7 +5184,8 @@ header() returns the Content-type: header. You can provide your own
MIME type if you choose, otherwise it defaults to text/html. An
optional second parameter specifies the status code and a human-readable
message. For example, you can specify 204, "No response" to create a
-script that tells the browser to do nothing at all.
+script that tells the browser to do nothing at all. Note that RFC 2616 expects
+the human-readable phase to be there as well as the numeric status code.
The last example shows the named argument style for passing arguments
to the CGI methods using named parameters. Recognized parameters are
@@ -5272,7 +5273,7 @@ You can also use named arguments:
print $q->redirect(
-uri=>'http://somewhere.else/in/movie/land',
-nph=>1,
- -status=>301);
+ -status=>'301 Moved Permanently');
All names arguments recognized by header() are also recognized by
redirect(). However, most HTTP headers, including those generated by
@@ -5295,6 +5296,9 @@ You may change the status to another status code if you wish. Be
advised that changing the status to anything other than 301, 302 or
303 will probably break redirection.
+Note that the human-readable phrase is also expected to be present to conform
+with RFC 2616, section 6.1.
+
=head2 CREATING THE HTML DOCUMENT HEADER
print start_html(-title=>'Secrets of the Pyramids',
View
25 t/url.t
@@ -25,20 +25,23 @@ is url() => 'http://proxy', 'url() with default port';
subtest 'rewrite_interactions' => sub {
# Reference: RT#45019
- local %ENV = (
- # These two are always set
- 'SCRIPT_NAME' => '/real/cgi-bin/dispatch.cgi',
- 'SCRIPT_FILENAME' => '/home/mark/real/path/cgi-bin/dispatch.cgi',
+ local $ENV{HTTP_X_FORWARDED_HOST} = undef;
+ local $ENV{SERVER_PROTOCOL} = undef;
+ local $ENV{SERVER_PORT} = undef;
+ local $ENV{SERVER_NAME} = undef;
- # These two are added by mod_rewrite Ref: http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
+ # These two are always set
+ local $ENV{'SCRIPT_NAME'} = '/real/cgi-bin/dispatch.cgi';
+ local $ENV{'SCRIPT_FILENAME'} = '/home/mark/real/path/cgi-bin/dispatch.cgi';
- 'SCRIPT_URL' => '/real/path/info',
- 'SCRIPT_URI' => 'http://example.com/real/path/info',
+ # These two are added by mod_rewrite Ref: http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
- 'PATH_INFO' => '/path/info',
- 'REQUEST_URI' => '/real/path/info',
- 'HTTP_HOST' => 'example.com'
- );
+ local $ENV{'SCRIPT_URL'} = '/real/path/info';
+ local $ENV{'SCRIPT_URI'} = 'http://example.com/real/path/info';
+
+ local $ENV{'PATH_INFO'} = '/path/info';
+ local $ENV{'REQUEST_URI'} = '/real/path/info';
+ local $ENV{'HTTP_HOST'} = 'example.com';
my $q = CGI->new;
Please sign in to comment.
Something went wrong with that request. Please try again.