Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/httpd some fixes for virtual hosting support from Ra...



details:   https://anonhg.NetBSD.org/src/rev/d9865474fe37
branches:  trunk
changeset: 326639:d9865474fe37
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sun Feb 09 01:46:10 2014 +0000

description:
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:

 libexec/httpd/bozohttpd.8 |  10 ++++++++--
 libexec/httpd/bozohttpd.c |  42 ++++++++++++++++++++++++------------------
 libexec/httpd/bozohttpd.h |   5 +++--
 3 files changed, 35 insertions(+), 22 deletions(-)

diffs (161 lines):

diff -r 466e177d3d57 -r d9865474fe37 libexec/httpd/bozohttpd.8
--- a/libexec/httpd/bozohttpd.8 Sat Feb 08 22:36:50 2014 +0000
+++ b/libexec/httpd/bozohttpd.8 Sun Feb 09 01:46:10 2014 +0000
@@ -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 @@
 .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 @@
 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@localhost
+provided several fixes for virtual hosting
+.It
 .An Jeremy C. Reed
 .Aq Mt reed%NetBSD.org@localhost
 provided several clean up fixes, and man page updates
diff -r 466e177d3d57 -r d9865474fe37 libexec/httpd/bozohttpd.c
--- a/libexec/httpd/bozohttpd.c Sat Feb 08 22:36:50 2014 +0000
+++ b/libexec/httpd/bozohttpd.c Sun Feb 09 01:46:10 2014 +0000
@@ -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 @@
        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 @@
                        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 @@
                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 @@
        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 -r 466e177d3d57 -r d9865474fe37 libexec/httpd/bozohttpd.h
--- a/libexec/httpd/bozohttpd.h Sat Feb 08 22:36:50 2014 +0000
+++ b/libexec/httpd/bozohttpd.h Sun Feb 09 01:46:10 2014 +0000
@@ -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 @@
        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;



Home | Main Index | Thread Index | Old Index