2001-08-13
2001-08-13 18:28:55 by Martin Stjernholm <mast@lysator.liu.se>
-
fce66d0dccbf50b45aaf410b8183a00403b532a1
(25 lines)
(+14/-11)
[
Show
| Annotate
]
Branch: 5.2
Fixed handling of the host header for clients (e.g. ApacheBench) that
doesn't send the port part.
Rev: server/protocols/http.pike:1.326
2:
// Modified by Francesco Chemolli to add throttling capabilities.
// Copyright © 1996 - 2000, Roxen IS.
- constant cvs_version = "$Id: http.pike,v 1.325 2001/08/09 14:08:13 jonasw Exp $";
+ constant cvs_version = "$Id: http.pike,v 1.326 2001/08/13 18:28:55 mast Exp $";
// #define REQUEST_DEBUG
#define MAGIC_ERROR
459: Inside #if defined(OLD_RXML_CONFIG)
};
void do_send_reply( string what, string url ) {
- if( misc->host )
- url= port_obj->name+"://"+misc->host + url;
- else if (conf)
- url = conf->query("MyWorldLocation") + url[1..];
+ url = url_base() + url[1..];
my_fd->write( prot + " 302 Roxen config coming up\r\n"+
(what?what+"\r\n":"")+"Location: "+url+
"Connection: close\r\nDate: "+
1904:
if (!cached_url_base) {
// First look at the host header in the request.
if (string tmp = misc->host) {
- string default_port = ":" + (port_obj && port_obj->default_port);
- if (has_suffix (tmp, default_port))
+ int scanres = sscanf (tmp, "%[^:]:%d", string host, int port);
+ if (scanres < 2)
+ // Some clients don't send the port in the host header.
+ port = port_obj->port;
+ if (port_obj->default_port == port)
// Remove redundant port number.
- cached_url_base = port_obj->prot_name + "://" +
- tmp[..sizeof (tmp) - sizeof (default_port) - 1];
+ cached_url_base = port_obj->prot_name + "://" + host;
else
-
+ if (scanres < 2)
+ cached_url_base = port_obj->prot_name + "://" + host + ":" + port;
+ else
cached_url_base = port_obj->prot_name + "://" + tmp;
}
2012:
port_obj->find_configuration_for_url(port_obj->name + "://" +
(misc->host||"*") +
(search(misc->host||"", ":")<0?
- (":"+port_obj->default_port):"") +
+ (":"+port_obj->port):"") +
raw_url,
this_object());
}