Skip to content

Commit

Permalink
adding server_tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
xsawyerx committed Aug 15, 2011
1 parent 6f2191c commit 8d41bc5
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 4 deletions.
5 changes: 5 additions & 0 deletions doc/service-parameters.txt
Expand Up @@ -91,6 +91,11 @@ For all services:
| | | |where trusted means their |
| | | |X-Forwarded-For/etc headers|
| | | |are not munged. |
|---------------------------+----+---------------------+---------------------------|
| | | |Whether to provide a |
|server_tokens |bool|true |'Server' header in the |
| | | |headers that are sent back |
| | | |to the user |
+----------------------------------------------------------------------------------+

Only for 'reverse_proxy' services:
Expand Down
8 changes: 4 additions & 4 deletions lib/Perlbal/ClientHTTPBase.pm
Expand Up @@ -541,7 +541,7 @@ sub _serve_request {

# now set whether this is keep-alive or not
$res->header("Date", HTTP::Date::time2str());
$res->header("Server", "Perlbal");
$res->header("Server", "Perlbal") if $self->{service}{server_tokens};
$res->header("Last-Modified", $lastmod);

if (-f _) {
Expand Down Expand Up @@ -708,7 +708,7 @@ sub _serve_request_multiple_poststat {
}

$res->header("Date", HTTP::Date::time2str());
$res->header("Server", "Perlbal");
$res->header("Server", "Perlbal") if $self->{service}{server_tokens};
$res->header("Last-Modified", $lastmod);
$res->header("Content-Type", $mime);
# has to happen after content-length is set to work:
Expand Down Expand Up @@ -852,7 +852,7 @@ sub _simple_response {
$res->header('Content-Length', length($body));
}

$res->header('Server', 'Perlbal');
$res->header('Server', 'Perlbal') if $self->{service}{server_tokens};

$self->setup_keepalive($res);

Expand Down Expand Up @@ -899,7 +899,7 @@ sub send_full_response {
$res->header('Content-Length', length($$bref));
}

$res->header('Server', 'Perlbal'); # Tunable?
$res->header('Server', 'Perlbal') if $self->{service}{server_tokens};
# $res->header('Date', # We should do this

$self->setup_keepalive($res, $options->{persist_client});
Expand Down
5 changes: 5 additions & 0 deletions lib/Perlbal/Manual/Internals.pod
Expand Up @@ -1009,6 +1009,11 @@ Comma-separated seconds (full or partial) to delay between retries.
Milliseconds of latency to add to request.


=item server_tokens

Boolean; whether to provide a "Server" header.


=item _stat_requests

Total requests to this service.
Expand Down
8 changes: 8 additions & 0 deletions lib/Perlbal/Manual/ReverseProxy.pod
Expand Up @@ -310,6 +310,14 @@ What path the OPTIONS request sent by C<verify_backend> should use.

Default is C<*>.

=item B<server_tokens> = bool

Whether to provide a "Server" header.

Perlbal by default adds a header to all replies (such as the web_server role). By setting this default to "off", you can prevent Perlbal from identifying itself.

Default is C<on>.

=back


Expand Down
8 changes: 8 additions & 0 deletions lib/Perlbal/Manual/WebServer.pod
Expand Up @@ -107,6 +107,14 @@ If PUT requests are enabled, require this many levels of directories to already

Default is 0.

=item B<server_tokens> = bool

Whether to provide a "Server" header.

Perlbal by default adds a header to all replies (such as the web_server role). By setting this default to "off", you can prevent Perlbal from identifying itself.

Default is C<on>.


=back

Expand Down
7 changes: 7 additions & 0 deletions lib/Perlbal/Service.pm
Expand Up @@ -101,6 +101,7 @@ use fields (
'enable_error_retries', # bool: whether we should retry requests after errors
'error_retry_schedule', # string of comma-separated seconds (full or partial) to delay between retries
'latency', # int: milliseconds of latency to add to request
'server_tokens', # bool: whether to provide a "Server" header

# stats:
'_stat_requests', # total requests to this service
Expand Down Expand Up @@ -611,6 +612,12 @@ our $tunables = {
check_role => '*',
},

'server_tokens' => {
des => 'Whether to provide a "Server" header.',
check_role => '*',
check_type => 'bool',
default => 1,
},

};
sub autodoc_get_tunables { return $tunables; }
Expand Down

0 comments on commit 8d41bc5

Please sign in to comment.