Skip to content

Commit

Permalink
Merge pull request #24 from waynieack/HTTP_Updates
Browse files Browse the repository at this point in the history
Http updates
  • Loading branch information
hplato authored Sep 19, 2017
2 parents 1ec08e0 + 324c3f0 commit 15fa4d2
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions lib/http_server.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,10 @@ sub Http10ResponseCheck {
$html = &AddContentLength($html) unless $NoContentLength; # Add content-length unless requested not to, we sometimes do it outside here.
return $html;
}
elsif ($html =~ /\A^HTTP\/1\.0/) {
print "http: Http10ResponseCheck found http 1.0 header, setting connection for close after response\n" if $main::Debug{http};
$Http{Connection} = 'close';
}

return $html;
}
Expand Down Expand Up @@ -1873,7 +1877,7 @@ sub html_form_select_set_var {

sub html_file {
my ( $socket, $file, $arg, $no_header ) = @_;
print "http: print html file=$file arg=$arg\n" if $main::Debug{http};
print "http: print html file=$file arg=$arg no_header=$no_header\n" if $main::Debug{http};

# Do not cach shtml files
my ($cache) = ( $file =~ /\.shtm?l?$/ or $file =~ /\.vxml?$/ ) ? 0 : 1;
Expand Down Expand Up @@ -1958,6 +1962,7 @@ sub html_file {
}
else {
$html = eval $code;
print "http: html_file - eval file: $file\n" if $main::Debug{http};
if ($@) {
my $msg = "http error in http eval of $file: $@";
$html = &html_page( '', $msg );
Expand All @@ -1968,9 +1973,10 @@ sub html_file {
}

# Drop the http header if no_header
$html =~ s/^HTTP.+?^$//smi if $no_header;
#$html =~ s/^HTTP.+?^$//smi if $no_header;
$html =~ s/\A^HTTP.+?^\R//smi if $no_header;

# print "Http_server .pl file results:$html.\n" if $main::Debug{http};
#print "http: .pl file results:$html.\n" if $main::Debug{http};
}
else {
print "http: Reading file: $file\n" if $main::Debug{http};
Expand Down Expand Up @@ -2204,6 +2210,10 @@ sub html_page {
# are sent later by the changeChecker
my %HttpHeader = &::http_get_headers($client_number,$requestnum);

print "http: html_page - title: $title style: $style script: $script
frame: $frame client#: $client_number req#: $requestnum\n"
if $main::Debug{http};;

# Allow for fully formated html
if ( $body =~ /^\s*<(!doctype\s*)?(html|\?xml)/i ) {
$body =~ s/\n/\n\r/g; # Bill S. says this is required to be standards compiliant
Expand All @@ -2222,7 +2232,7 @@ sub html_page {
$html_head .= "Date: " . time2str(time) . "\r\n";
$html_head .= "Cache-Control: no-cache\r\n";
$html_head .= "\r\n";

return $html_head.$body;
}

Expand Down Expand Up @@ -2280,6 +2290,7 @@ sub html_page {
$html_head .= "\r\n";

return $html_head.$html;

}

sub http_redirect {
Expand Down

0 comments on commit 15fa4d2

Please sign in to comment.