[BACK]Return to bozohttpd.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / libexec / httpd

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/libexec/httpd/bozohttpd.c between version 1.77 and 1.78

version 1.77, 2015/12/31 04:58:43 version 1.78, 2016/01/02 18:40:13
Line 347  bozo_clean_request(bozo_httpreq_t *reque
Line 347  bozo_clean_request(bozo_httpreq_t *reque
                 free(ohdr);                  free(ohdr);
                 ohdr = hdr;                  ohdr = hdr;
         }          }
           for (hdr = SIMPLEQ_FIRST(&request->hr_replheaders); hdr;
               hdr = SIMPLEQ_NEXT(hdr, h_next)) {
                   free(hdr->h_value);
                   free(hdr->h_header);
                   free(ohdr);
                   ohdr = hdr;
           }
         free(ohdr);          free(ohdr);
   
         free(request);          free(request);
Line 363  alarmer(int sig)
Line 370  alarmer(int sig)
 }  }
   
 /*  /*
    * a list of header quirks: currently, a list of headers that
    * can't be folded into a single line.
    */
   const char *header_quirks[] = { "WWW-Authenticate", NULL };
   
   /*
  * add or merge this header (val: str) into the requests list   * add or merge this header (val: str) into the requests list
  */   */
 static bozoheaders_t *  static bozoheaders_t *
 addmerge_header(bozo_httpreq_t *request, char *val,  addmerge_header(bozo_httpreq_t *request, struct qheaders *headers,
                 char *str, ssize_t len)                  const char *val, const char *str, ssize_t len)
 {  {
         struct  bozohttpd_t *httpd = request->hr_httpd;          struct  bozohttpd_t *httpd = request->hr_httpd;
         struct  bozoheaders *hdr;          struct bozoheaders       *hdr = NULL;
           const char              **quirk;
   
         USE_ARG(len);          USE_ARG(len);
         /* do we exist already? */          for (quirk = header_quirks; *quirk; quirk++)
         SIMPLEQ_FOREACH(hdr, &request->hr_headers, h_next) {                  if (strcasecmp(*quirk, val) == 0)
                 if (strcasecmp(val, hdr->h_header) == 0)  
                         break;                          break;
   
           if (*quirk == NULL) {
                   /* do we exist already? */
                   SIMPLEQ_FOREACH(hdr, headers, h_next) {
                           if (strcasecmp(val, hdr->h_header) == 0)
                                   break;
                   }
         }          }
   
         if (hdr) {          if (hdr) {
Line 396  addmerge_header(bozo_httpreq_t *request,
Line 416  addmerge_header(bozo_httpreq_t *request,
                 else                  else
                         hdr->h_value = bozostrdup(httpd, request, " ");                          hdr->h_value = bozostrdup(httpd, request, " ");
   
                 SIMPLEQ_INSERT_TAIL(&request->hr_headers, hdr, h_next);                  SIMPLEQ_INSERT_TAIL(headers, hdr, h_next);
                 request->hr_nheaders++;                  request->hr_nheaders++;
         }          }
   
         return hdr;          return hdr;
 }  }
   
   bozoheaders_t *
   addmerge_reqheader(bozo_httpreq_t *request, const char *val, const char *str,
                      ssize_t len)
   {
   
           return addmerge_header(request, &request->hr_headers, val, str, len);
   }
   
   bozoheaders_t *
   addmerge_replheader(bozo_httpreq_t *request, const char *val, const char *str,
                       ssize_t len)
   {
   
           return addmerge_header(request, &request->hr_replheaders,
               val, str, len);
   }
   
 /*  /*
  * as the prototype string is not constant (eg, "HTTP/1.1" is equivalent   * as the prototype string is not constant (eg, "HTTP/1.1" is equivalent
  * to "HTTP/001.01"), we MUST parse this.   * to "HTTP/001.01"), we MUST parse this.
Line 538  bozo_read_request(bozohttpd_t *httpd)
Line 575  bozo_read_request(bozohttpd_t *httpd)
         request->hr_virthostname = NULL;          request->hr_virthostname = NULL;
         request->hr_file = NULL;          request->hr_file = NULL;
         request->hr_oldfile = NULL;          request->hr_oldfile = NULL;
           SIMPLEQ_INIT(&request->hr_replheaders);
         bozo_auth_init(request);          bozo_auth_init(request);
   
         slen = sizeof(ss);          slen = sizeof(ss);
Line 673  bozo_read_request(bozohttpd_t *httpd)
Line 711  bozo_read_request(bozohttpd_t *httpd)
                         if (bozo_auth_check_headers(request, val, str, len))                          if (bozo_auth_check_headers(request, val, str, len))
                                 goto next_header;                                  goto next_header;
   
                         hdr = addmerge_header(request, val, str, len);                          hdr = addmerge_reqheader(request, val, str, len);
   
                         if (strcasecmp(hdr->h_header, "content-type") == 0)                          if (strcasecmp(hdr->h_header, "content-type") == 0)
                                 request->hr_content_type = hdr->h_value;                                  request->hr_content_type = hdr->h_value;
Line 1680  bozo_print_header(bozo_httpreq_t *reques
Line 1718  bozo_print_header(bozo_httpreq_t *reques
         bozohttpd_t *httpd = request->hr_httpd;          bozohttpd_t *httpd = request->hr_httpd;
         off_t len;          off_t len;
         char    date[40];          char    date[40];
           bozoheaders_t *hdr;
   
           SIMPLEQ_FOREACH(hdr, &request->hr_replheaders, h_next) {
                   bozo_printf(httpd, "%s: %s\r\n", hdr->h_header,
                                   hdr->h_value);
           }
   
         bozo_printf(httpd, "Date: %s\r\n", bozo_http_date(date, sizeof(date)));          bozo_printf(httpd, "Date: %s\r\n", bozo_http_date(date, sizeof(date)));
         bozo_printf(httpd, "Server: %s\r\n", httpd->server_software);          bozo_printf(httpd, "Server: %s\r\n", httpd->server_software);
Line 1901  bozo_http_error(bozohttpd_t *httpd, int 
Line 1945  bozo_http_error(bozohttpd_t *httpd, int 
         const char *proto = (request && request->hr_proto) ?          const char *proto = (request && request->hr_proto) ?
                                 request->hr_proto : httpd->consts.http_11;                                  request->hr_proto : httpd->consts.http_11;
         int     size;          int     size;
           bozoheaders_t *hdr;
   
         debug((httpd, DEBUG_FAT, "bozo_http_error %d: %s", code, msg));          debug((httpd, DEBUG_FAT, "bozo_http_error %d: %s", code, msg));
         if (header == NULL || reason == NULL) {          if (header == NULL || reason == NULL) {
Line 1963  bozo_http_error(bozohttpd_t *httpd, int 
Line 2008  bozo_http_error(bozohttpd_t *httpd, int 
                 size = 0;                  size = 0;
   
         bozo_printf(httpd, "%s %s\r\n", proto, header);          bozo_printf(httpd, "%s %s\r\n", proto, header);
         if (request)  
           if (request) {
                 bozo_auth_check_401(request, code);                  bozo_auth_check_401(request, code);
                   SIMPLEQ_FOREACH(hdr, &request->hr_replheaders, h_next) {
                           bozo_printf(httpd, "%s: %s\r\n", hdr->h_header,
                                           hdr->h_value);
                   }
           }
   
         bozo_printf(httpd, "Content-Type: text/html\r\n");          bozo_printf(httpd, "Content-Type: text/html\r\n");
         bozo_printf(httpd, "Content-Length: %d\r\n", size);          bozo_printf(httpd, "Content-Length: %d\r\n", size);

Legend:
Removed from v.1.77  
changed lines
  Added in v.1.78

CVSweb <webmaster@jp.NetBSD.org>