Skip to content

Commit

Permalink
HTTP 1.1 Update #1
Browse files Browse the repository at this point in the history
  • Loading branch information
waynieack committed Aug 12, 2017
1 parent 5b278e3 commit d998b8a
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 65 deletions.
103 changes: 51 additions & 52 deletions lib/http_server.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1620,7 +1620,10 @@ sub html_file {
print "db web file cache check: f=$file t=$time2/$time3\n"
if $main::Debug{http};
if ( $time3 <= $time2 ) {
return "HTTP/1.0 304 Not Modified\nServer: MisterHouse\n\n";
my $html_head = "HTTP/1.1 304 Not Modified\r\n";
$html_head .= "Server: MisterHouse\r\n";
$html_head .= "Date: " . time2str(time) . "\r\n";
$html_head .= "\r\n";
}
}

Expand Down Expand Up @@ -1889,7 +1892,7 @@ sub mime_header {
}

# print "dbx2 m=$mime f=$file_or_type\n";
my $code = "HTTP/1.0 200 OK";
my $code = "HTTP/1.1 200 OK";
$code = "HTTP/1.1 206 Partial Content" if $range;
my $header = "$code\nServer: MisterHouse\nContent-Type: $mime\n";

Expand Down Expand Up @@ -1933,21 +1936,18 @@ sub html_alias {

# Responses documented here: http://www.w3.org/Protocols/HTTP/HTRESP.html
sub html_no_response {

return <<eof;
HTTP/1.0 204 No Response
Server: MisterHouse
Content-Type: text/html
eof
my $html_head = "HTTP/1.1 204 No Content\r\n";
$html_head .= "Server: MisterHouse\r\n";
$html_head .= "Content-type: text/html\r\n";
$html_head .= "Date: " . time2str(time) . "\r\n";
$html_head .= "\r\n";
return $html_head;
}

sub html_page {
my ( $title, $body, $style, $script, $frame ) = @_;

my $date = time2str(time);

my $html_head;
# 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 @@ -1958,20 +1958,15 @@ sub html_page {
$contenttype = "text/xml";
}

# Content-Length is only for binary data!
# my $length = length $body;
# Content-Length: $length

#Cache-Control: max-age=1000000
return <<eof;
HTTP/1.0 200 OK
Server: MisterHouse
Date: $date
Content-Type: $contenttype
Cache-Control: no-cache
$html_head = "HTTP/1.1 200 OK\r\n";
$html_head .= "Server: MisterHouse\r\n";
$html_head .= "Content-type: $contenttype\r\n";
$html_head .= "Content-Length: " . ( length $body ) . "\r\n";
$html_head .= "Date: " . time2str(time) . "\r\n";
$html_head .= "Cache-Control: no-cache\r\n";
$html_head .= "\r\n";

$body
eof
return $html_head.$body;
}

$body = 'No data' unless $body;
Expand Down Expand Up @@ -2001,7 +1996,7 @@ sub html_page {
unless $script =~ / script /i;
$html = $script . "\n";
}
$html .= "<HTML>
$html .= "<HTML>
<HEAD>
$style
<TITLE>$title</TITLE>
Expand All @@ -2013,22 +2008,20 @@ sub html_page {
</HTML>
";

my $extraheaders = '';
$extraheaders .= $Cookie . "\n\r" if $Cookie;
$extraheaders .= $frame . "\n\r" if $frame;
$extraheaders .= "\n\r" if $extraheaders;

# Not sure how important length is, but pretty cheap and easy to do
$html =~ s/\n/\n\r/g; # Bill S. says this is required to be standards compiliant
return <<eof;
HTTP/1.0 200 OK
Server: MisterHouse
Content-Type: text/html
Cache-Control: no-cache
$extraheaders
$html =~ s/\n/\n\r/g; # Bill S. says this is required to be standards compiliant

$html
eof
$html_head = "HTTP/1.1 200 OK\r\n";
$html_head .= "Server: MisterHouse\r\n";
$html_head .= "Content-type: text/html\r\n";
$html_head .= "Content-Length: " . ( length $html ) . "\r\n";
$html_head .= "Date: " . time2str(time) . "\r\n";
$html_head .= "Cache-Control: no-cache\r\n";
$html_head .= $Cookie . "\n\r" if $Cookie;
$html_head .= $frame . "\n\r" if $frame;
$html_head .= "\r\n";

return $html_head.$html;
}

sub http_redirect {
Expand Down Expand Up @@ -3266,14 +3259,7 @@ sub vars_global {
sub vxml_page {
my ($vxml) = @_;

my $header = "Content-type: text/xml";

# $header = $Cookie . $header if $Cookie;

return <<eof;
HTTP/1.0 200 OK
Server: MisterHouse
$header
my $html = <<eof;
<?xml version="1.0" encoding="UTF-8"?>
<vxml version="2.0"
Expand All @@ -3284,6 +3270,14 @@ sub vxml_page {
</vxml>
eof

my $html_head = "HTTP/1.1 200 OK\r\n";
$html_head .= "Server: MisterHouse\r\n";
$html_head .= "Content-type: text/xml\r\n";
$html_head .= "Content-Length: " . ( length $html ) . "\r\n";
$html_head .= "Date: " . time2str(time) . "\r\n";
$html_head .= "\r\n";

return $html_head.$html;
}

# vxml for audio text/wav followed by a goto
Expand Down Expand Up @@ -3645,9 +3639,6 @@ sub dir_index {
sub wml_page {
my ($wml) = @_;
$wml = <<"eof";
HTTP/1.0 200 OK
Server: MisterHouse
Content-Type: text/vnd.wap.wml
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//PHONE.COM//DTD WML 1.1//EN"
Expand All @@ -3656,7 +3647,15 @@ sub wml_page {
$wml
</wml>
eof
return $wml;

my $html_head = "HTTP/1.1 200 OK\r\n";
$html_head .= "Server: MisterHouse\r\n";
$html_head .= "Content-type: text/vnd.wap.wml\r\n";
$html_head .= "Content-Length: " . ( length $wml ) . "\r\n";
$html_head .= "Date: " . time2str(time) . "\r\n";
$html_head .= "\r\n";

return $html_head.$wml;
}

return 1; # Make require happy
Expand Down
39 changes: 26 additions & 13 deletions lib/xml_server.pl
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,7 @@ sub xml_page {
# handle blank xsl name
my $style;
$style = qq|<?xml-stylesheet type="text/xsl" href="$xsl"?>| if $xsl;
return <<eof;
HTTP/1.0 200 OK
Server: MisterHouse
Content-type: text/xml
my $html = <<eof;
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
$style
Expand All @@ -508,6 +505,14 @@ sub xml_page {
eof

my $html_head = "HTTP/1.1 200 OK\r\n";
$html_head .= "Server: MisterHouse\r\n";
$html_head .= "Content-type: text/xml\r\n";
$html_head .= "Content-Length: " . ( length $html ) . "\r\n";
$html_head .= "Date: " . time2str(time) . "\r\n";
$html_head .= "\r\n";

return $html_head.$html;
}

sub xml_entities_encode {
Expand All @@ -522,22 +527,23 @@ sub xml_entities_encode {

sub svg_page {
my ($svg) = @_;
return <<eof;
HTTP/1.0 200 OK
Server: Homegrow
Content-type: image/svg+xml
my $html = <<eof;
$svg
eof

my $html_head = "HTTP/1.1 200 OK\r\n";
$html_head .= "Server: MisterHouse\r\n";
$html_head .= "Content-type: image/svg+xml\r\n";
$html_head .= "Content-Length: " . ( length $html ) . "\r\n";
$html_head .= "Date: " . time2str(time) . "\r\n";
$html_head .= "\r\n";

return $html_head.$html;
}

sub xml_usage {
my $html = <<eof;
HTTP/1.0 200 OK
Server: MisterHouse
Content-type: text/html
<html>
<head>
</head>
Expand Down Expand Up @@ -582,7 +588,14 @@ sub xml_usage {
</html>
eof

return $html;
my $html_head = "HTTP/1.1 200 OK\r\n";
$html_head .= "Server: MisterHouse\r\n";
$html_head .= "Content-type: text/html\r\n";
$html_head .= "Content-Length: " . ( length $html ) . "\r\n";
$html_head .= "Date: " . time2str(time) . "\r\n";
$html_head .= "\r\n";

return $html_head.$html;
}

return 1; # Make require happy
Expand Down

0 comments on commit d998b8a

Please sign in to comment.