Omit the version number from headers and HTML responses (#543)

Omit the version number from headers, HTML responses, and templates
This commit is contained in:
James McKinney 2024-06-20 04:51:29 -04:00 committed by GitHub
parent 72b93f6d4b
commit d652ed8538
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 21 additions and 27 deletions

View File

@ -30,9 +30,6 @@
<dt>clienthost</dt>
<dd>{clienthost}</dd>
<dt>version</dt>
<dd>{version}</dd>
<dt>package</dt>
<dd>{package}</dd>
@ -49,7 +46,7 @@
<hr />
<p><em>Generated by <a href="{website}">{package}</a> version {version}.</em></p>
<p><em>Generated by <a href="{website}">{package}</a>.</em></p>
</body>

View File

@ -16,7 +16,7 @@
<hr />
<p><em>Generated by <a href="{website}">{package}</a> version {version}.</em></p>
<p><em>Generated by <a href="{website}">{package}</a>.</em></p>
</body>

View File

@ -2,7 +2,7 @@
<html lang="en">
<head>
<title>Stats [{package} v{version}]</title>
<title>Stats [{package}]</title>
<meta charset="UTF-8" />
<style type="text/css">
body {
@ -62,7 +62,7 @@
<div id="inner">
<table>
<tr>
<th colspan="2">{package} v{version} statistics</th>
<th colspan="2">{package} statistics</th>
</tr>
<tr class="odd">
<td class="right">Open connections</td>

View File

@ -140,14 +140,14 @@ int send_http_headers (
{
const char headers[] =
"HTTP/1.%u %d %s\r\n"
"Server: %s/%s\r\n"
"Server: %s\r\n"
"Content-Type: text/html\r\n"
"%s"
"Connection: close\r\n" "\r\n";
return (write_message (connptr->client_fd, headers,
connptr->protocol.major != 1 ? 0 : connptr->protocol.minor,
code, message, PACKAGE, VERSION,
code, message, PACKAGE,
extra));
}
@ -169,7 +169,7 @@ int send_http_error_message (struct conn_s *connptr)
"<h1>%s</h1>\n"
"<p>%s</p>\n"
"<hr />\n"
"<p><em>Generated by %s version %s.</em></p>\n" "</body>\n"
"<p><em>Generated by %s.</em></p>\n" "</body>\n"
"</html>\n";
const char p_auth_str[] =
@ -199,7 +199,7 @@ int send_http_error_message (struct conn_s *connptr)
connptr->error_number,
connptr->error_string,
connptr->error_string,
detail, PACKAGE, VERSION));
detail, PACKAGE));
}
ret = send_html_file (infile, connptr);

View File

@ -308,7 +308,7 @@ static int send_connect_method_response (struct conn_s *connptr)
{
return write_message (connptr->client_fd,
"HTTP/1.%u 200 Connection established\r\n"
"Proxy-agent: " PACKAGE "/" VERSION "\r\n"
"Proxy-agent: " PACKAGE "\r\n"
"\r\n", connptr->protocol.major != 1 ? 0 :
connptr->protocol.minor);
}
@ -881,15 +881,14 @@ write_via_header (int fd, orderedmap hashofheaders,
data = orderedmap_find (hashofheaders, "via");
if (data) {
ret = write_message (fd,
"Via: %s, %hu.%hu %s (%s/%s)\r\n",
data, major, minor, hostname, PACKAGE,
VERSION);
"Via: %s, %hu.%hu %s (%s)\r\n",
data, major, minor, hostname, PACKAGE);
orderedmap_remove (hashofheaders, "via");
} else {
ret = write_message (fd,
"Via: %hu.%hu %s (%s/%s)\r\n",
major, minor, hostname, PACKAGE, VERSION);
"Via: %hu.%hu %s (%s)\r\n",
major, minor, hostname, PACKAGE);
}
done:

View File

@ -87,9 +87,9 @@ err_minus_one:
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" "
"\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n"
"<html>\n"
"<head><title>%s version %s run-time statistics</title></head>\n"
"<head><title>%s run-time statistics</title></head>\n"
"<body>\n"
"<h1>%s version %s run-time statistics</h1>\n"
"<h1>%s run-time statistics</h1>\n"
"<p>\n"
"Number of open connections: %lu<br />\n"
"Number of requests: %lu<br />\n"
@ -98,13 +98,13 @@ err_minus_one:
"Number of refused connections due to high load: %lu\n"
"</p>\n"
"<hr />\n"
"<p><em>Generated by %s version %s.</em></p>\n" "</body>\n"
"<p><em>Generated by %s.</em></p>\n" "</body>\n"
"</html>\n",
PACKAGE, VERSION, PACKAGE, VERSION,
PACKAGE, PACKAGE,
stats->num_open,
stats->num_reqs,
stats->num_badcons, stats->num_denied,
stats->num_refused, PACKAGE, VERSION);
stats->num_refused, PACKAGE);
if (send_http_message (connptr, 200, "OK",
message_buffer) < 0) {

View File

@ -39,7 +39,7 @@ send_http_message (struct conn_s *connptr, int http_code,
const char *error_title, const char *message)
{
static const char *headers[] = {
"Server: " PACKAGE "/" VERSION,
"Server: " PACKAGE,
"Content-type: text/html",
"Connection: close"
};

View File

@ -26,9 +26,8 @@ use Pod::Usage;
my $EOL = "\015\012";
my $VERSION = "0.1";
my $NAME = "Tinyproxy-Web-Client";
my $user_agent = "$NAME/$VERSION";
my $user_agent = "$NAME";
my $user_agent_header = "User-Agent: $user_agent$EOL";
my $http_version = "1.0";
my $method = "GET";

View File

@ -31,9 +31,8 @@ use Getopt::Long;
use Pod::Usage;
use Fcntl ':flock'; # import LOCK_* constants
my $VERSION = "0.1";
my $NAME = "Tinyproxy-Test-Web-Server";
my $server_header = "Server: $NAME/$VERSION";
my $server_header = "Server: $NAME";
my $EOL = "\015\012";