diff options
| author | mrg <mrg@NetBSD.org> | 2014-02-09 01:46:10 +0000 |
|---|---|---|
| committer | mrg <mrg@NetBSD.org> | 2014-02-09 01:46:10 +0000 |
| commit | b7e29a155dbb970cc0fc42bd17df93e4ef867c54 (patch) | |
| tree | 253ce4df0d8b96c7a98f57aeac3a49837f7882c9 /libexec/httpd | |
| parent | 29c4a3fdf3c798d3d0b7ac8c8982827000cf7009 (diff) | |
some fixes for virtual hosting support from Rajeev V. Pillai:
- memory leaks in virtual host plugged
- ensure hr_host is only the host/port part when the request
contains the hostname in the URI not Host: header.
also update the references to the old http/1.1 draft rev 06
to RFC 2616 (fortunately, most sections hadn't moved.)
Diffstat (limited to 'libexec/httpd')
| -rw-r--r-- | libexec/httpd/bozohttpd.8 | 10 | ||||
| -rw-r--r-- | libexec/httpd/bozohttpd.c | 42 | ||||
| -rw-r--r-- | libexec/httpd/bozohttpd.h | 5 |
3 files changed, 35 insertions, 22 deletions
diff --git a/libexec/httpd/bozohttpd.8 b/libexec/httpd/bozohttpd.8 index ce32788c3d9..8753914da99 100644 --- a/libexec/httpd/bozohttpd.8 +++ b/libexec/httpd/bozohttpd.8 @@ -1,4 +1,4 @@ -.\" $NetBSD: bozohttpd.8,v 1.44 2014/02/02 03:13:31 mrg Exp $ +.\" $NetBSD: bozohttpd.8,v 1.45 2014/02/09 01:46:10 mrg Exp $ .\" .\" $eterna: bozohttpd.8,v 1.101 2011/11/18 01:25:11 mrg Exp $ .\" @@ -480,7 +480,9 @@ and inside .Pa /var/vroot create a directory (or a symlink to a directory) with the same name as the virtual host, for each virtual host. -Lookups for these names are done in a case-insensitive manner. +Lookups for these names are done in a case-insensitive manner, and may +include the port number part of the request, allowing for distinct +virtual hosts on the same name. .Pp To use .Nm @@ -614,6 +616,10 @@ option. provided many various fixes, including cgi-bin fixes and enhancements, HTTP basic authorisation support and much code clean up .It +.An Rajeev V. Pillai +.Aq Mt rajeev_v_pillai@yahoo.com +provided several fixes for virtual hosting +.It .An Jeremy C. Reed .Aq Mt reed@NetBSD.org provided several clean up fixes, and man page updates diff --git a/libexec/httpd/bozohttpd.c b/libexec/httpd/bozohttpd.c index 2ad5c40ff4d..88f310cbe9c 100644 --- a/libexec/httpd/bozohttpd.c +++ b/libexec/httpd/bozohttpd.c @@ -1,4 +1,4 @@ -/* $NetBSD: bozohttpd.c,v 1.47 2014/02/02 03:13:31 mrg Exp $ */ +/* $NetBSD: bozohttpd.c,v 1.48 2014/02/09 01:46:10 mrg Exp $ */ /* $eterna: bozohttpd.c,v 1.178 2011/11/18 09:21:15 mrg Exp $ */ @@ -55,17 +55,17 @@ /* * requirements for minimal http/1.1 (at least, as documented in - * <draft-ietf-http-v11-spec-rev-06> which expired may 18, 1999): + * RFC 2616 (HTTP/1.1): * - * - 14.15: content-encoding handling. [1] + * - 14.11: content-encoding handling. [1] * - * - 14.16: content-length handling. this is only a SHOULD header + * - 14.13: content-length handling. this is only a SHOULD header * thus we could just not send it ever. [1] * * - 14.17: content-type handling. [1] * - * - 14.25/28: if-{,un}modified-since handling. maybe do this, but - * i really don't want to have to parse 3 differnet date formats + * - 14.28: if-unmodified-since handling. if-modified-since is + * done since, shouldn't be too hard for this one. * * [1] need to revisit to ensure proper behaviour * @@ -88,21 +88,21 @@ * * - 10.3.3/10.3.4/10.3.8: just use '302' codes always. * - * - 14.1/14.2/14.3/14.27: we do not support Accept: headers.. + * - 14.1/14.2/14.3/14.27: we do not support Accept: headers. * just ignore them and send the request anyway. they are * only SHOULD. * - * - 14.5/14.16/14.35: we don't do ranges. from section 14.35.2 - * `A server MAY ignore the Range header'. but it might be nice. - * since 20080301 we support simple range headers. + * - 14.5/14.16/14.35: only support simple ranges: %d- and %d-%d + * would be nice to support more. * * - 14.9: we aren't a cache. * - * - 14.15: content-md5 would be nice... + * - 14.15: content-md5 would be nice. * - * - 14.24/14.26/14.27: be nice to support this... + * - 14.24/14.26/14.27: if-match, if-none-match, if-range. be + * nice to support this. * - * - 14.44: not sure about this Vary: header. ignore it for now. + * - 14.44: Vary: seems unneeded. ignore it for now. */ #ifndef INDEX_HTML @@ -341,6 +341,7 @@ bozo_clean_request(bozo_httpreq_t *request) MF(hr_file); MF(hr_oldfile); MF(hr_query); + MF(hr_host); #undef MF bozo_auth_cleanup(request); for (hdr = SIMPLEQ_FIRST(&request->hr_headers); hdr; @@ -681,8 +682,8 @@ bozo_read_request(bozohttpd_t *httpd) else if (strcasecmp(hdr->h_header, "content-length") == 0) request->hr_content_length = hdr->h_value; else if (strcasecmp(hdr->h_header, "host") == 0) - request->hr_host = hdr->h_value; - /* HTTP/1.1 rev06 draft spec: 14.20 */ + request->hr_host = bozostrdup(httpd, hdr->h_value); + /* RFC 2616 (HTTP/1.1): 14.20 */ else if (strcasecmp(hdr->h_header, "expect") == 0) { (void)bozo_http_error(httpd, 417, request, "we don't support Expect:"); @@ -719,8 +720,9 @@ next_header: goto cleanup; } - /* HTTP/1.1 draft rev-06, 14.23 & 19.6.1.1 */ + /* RFC 2616 (HTTP/1.1), 14.23 & 19.6.1.1 */ if (request->hr_proto == httpd->consts.http_11 && + /*(strncasecmp(request->hr_file, "http://", 7) != 0) &&*/ request->hr_host == NULL) { (void)bozo_http_error(httpd, 400, request, "missing Host header"); @@ -1042,9 +1044,13 @@ check_virtual(bozo_httpreq_t *request) if (strncasecmp(file, "http://", 7) == 0) { /* we would do virtual hosting here? */ file += 7; + /* RFC 2616 (HTTP/1.1), 5.2: URI takes precedence over Host: */ + free(request->hr_host); + request->hr_host = bozostrdup(request->hr_httpd, file); + if ((s = strchr(request->hr_host, '/')) != NULL) + *s = '\0'; s = strchr(file, '/'); - /* HTTP/1.1 draft rev-06, 5.2: URI takes precedence over Host: */ - request->hr_host = file; + free(request->hr_file); request->hr_file = bozostrdup(request->hr_httpd, s ? s : "/"); debug((httpd, DEBUG_OBESE, "got host ``%s'' file is now ``%s''", request->hr_host, request->hr_file)); diff --git a/libexec/httpd/bozohttpd.h b/libexec/httpd/bozohttpd.h index 33c42b5e6ad..0a20e467e94 100644 --- a/libexec/httpd/bozohttpd.h +++ b/libexec/httpd/bozohttpd.h @@ -1,4 +1,4 @@ -/* $NetBSD: bozohttpd.h,v 1.31 2014/01/02 08:21:38 mrg Exp $ */ +/* $NetBSD: bozohttpd.h,v 1.32 2014/02/09 01:46:10 mrg Exp $ */ /* $eterna: bozohttpd.h,v 1.39 2011/11/18 09:21:15 mrg Exp $ */ @@ -145,11 +145,12 @@ typedef struct bozo_httpreq_t { char *hr_file; char *hr_oldfile; /* if we added an index_html */ char *hr_query; + char *hr_host; /* HTTP/1.1 Host: or virtual hostname, + possibly including a port number */ const char *hr_proto; const char *hr_content_type; const char *hr_content_length; const char *hr_allow; - const char *hr_host; /* HTTP/1.1 Host: */ const char *hr_referrer; const char *hr_range; const char *hr_if_modified_since; |
