Changeset 1091
- Timestamp:
- 06/18/07 16:20:16 (16 months ago)
- Location:
- trunk
- Files:
-
- 5 modified
-
lib/OpenGuides/Template.pm (modified) (4 diffs)
-
t/15_template.t (modified) (2 diffs)
-
t/58_navbar_common_locales_categories.t (modified) (1 diff)
-
t/59_preferences.t (modified) (1 diff)
-
wiki.cgi (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/OpenGuides/Template.pm
r1085 r1091 51 51 content_type => "text/html", 52 52 cookies => $cookie, 53 vars => {foo => "bar"} 53 vars => {foo => "bar"}, 54 noheaders => 1 54 55 ); 55 56 … … 111 112 Content-Type: defaults to C<text/html> and is omitted if the 112 113 C<content_type> arg is explicitly set to the blank string. 114 115 However, what you more often need is the C<noheaders> option, 116 which suppresses all HTTP headers, not just the Content-Type. 113 117 114 118 The HTTP response code may be explictly set with the C<http_status> arg. … … 188 192 189 193 my $header = ""; 190 my %cgi_header_args; 191 192 if ( defined $args{content_type} and $args{content_type} eq "" ) { 193 $cgi_header_args{'-type'} = ''; 194 } else { 195 if ( $args{content_type} ) { 196 $cgi_header_args{'-type'} = $args{content_type}; 194 195 unless ( $args{noheaders} ) { 196 my %cgi_header_args; 197 198 if ( defined $args{content_type} and $args{content_type} eq "" ) { 199 $cgi_header_args{'-type'} = ''; 197 200 } else { 198 $cgi_header_args{'-type'} = "text/html"; 199 } 201 if ( $args{content_type} ) { 202 $cgi_header_args{'-type'} = $args{content_type}; 203 } else { 204 $cgi_header_args{'-type'} = "text/html"; 205 } 206 } 207 200 208 if ( $tt_vars->{http_charset} ) { 201 209 $cgi_header_args{'-type'} .= "; charset=".$tt_vars->{http_charset}; 202 210 } 203 # XXX should possibly not be inside this block, but retaining204 # existing functionality for now. See205 # http://dev.openguides.org/ticket/220206 211 $cgi_header_args{'-cookie'} = $args{cookies}; 207 } 208 209 if ( $args{http_status} ) {210 $cgi_header_args{'-status'} = $args{http_status};211 } 212 213 $header = CGI::header( %cgi_header_args );212 213 if ( $args{http_status} ) { 214 $cgi_header_args{'-status'} = $args{http_status}; 215 } 216 217 $header = CGI::header( %cgi_header_args ); 218 } 214 219 215 220 # vile hack … … 220 225 metadata => {}, 221 226 ); 222 227 223 228 $tt_vars = { %field_vars, %$tt_vars }; 224 229 -
trunk/t/15_template.t
r1040 r1091 6 6 use OpenGuides::Template; 7 7 use OpenGuides::Test; 8 use Test::More tests => 2 8;8 use Test::More tests => 29; 9 9 10 10 my $config = OpenGuides::Test->make_basic_config; … … 51 51 unlike( $output, qr/^Content-Type: text\/html/, 52 52 "Content-Type header omitted if content_type arg explicitly blank" ); 53 54 $output = OpenGuides::Template->output( 55 wiki => $wiki, 56 config => $config, 57 template => "15_test.tt", 58 noheaders => 1, 59 http_response => 500 60 ); 61 62 unlike( $output, qr/^Status: /, 63 "Headers omitted if noheaders arg given" ); 53 64 54 65 $output = OpenGuides::Template->output( -
trunk/t/58_navbar_common_locales_categories.t
r1086 r1091 33 33 config => $guide->config, 34 34 template => "preferences.tt", 35 content_type => '',35 noheaders => 1, 36 36 vars => { 37 37 not_editable => 1, -
trunk/t/59_preferences.t
r1085 r1091 60 60 config => $config, 61 61 template => "preferences.tt", 62 content_type => '',62 noheaders => 1, 63 63 vars => { 64 64 not_editable => 1, -
trunk/wiki.cgi
r1057 r1091 303 303 vars => $vars 304 304 ); 305 $output_conf{ content_type} = ""if $omit_header; # defaults otherwise305 $output_conf{noheaders} = 1 if $omit_header; # defaults otherwise 306 306 print OpenGuides::Template->output( %output_conf ); 307 307 }
