httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Tromey <tro...@creche.cygnus.com>
Subject Re: CGI-related core
Date Tue, 01 Oct 1996 20:03:16 GMT
>   * I didn't understand why response_titles and status_lines were
>     separate.  I unified them.

Robert> The titles of a few common generated error response bodies are
Robert> chosen to be more meaningful to end users than the standard
Robert> suggested error texts

Ok.  But I doubt it is really important to use the precise text from
the HTTP spec in the status messages; my evidence for this is that
Apache currently diverges from the standard (eg in the standard 302 is
"Moved Temporarily" but Apache has "Found).

So in my local copy I replaced the text in status_lines with the more
user-friendly text.  I also got rid of the RESPONSE_CODE_LIST define,
as it is redundant and a pain to update.

Once again, the patch is appended.

Tom
-- 
tromey@cygnus.com                 Member, League for Programming Freedom

Index: http_protocol.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_protocol.c,v
retrieving revision 1.51
diff -c -5 -r1.51 http_protocol.c
*** http_protocol.c	1996/09/30 05:56:25	1.51
--- http_protocol.c	1996/10/01 19:57:55
***************
*** 789,865 ****
      *pw = t;
  
      return OK;
  }
  
- #define RESPONSE_CODE_LIST " 200 206 300 301 302 304 400 401 403 404 405 406 411 412 500
503 501 502 506"
- 
  /* New Apache routine to map error responses into array indicies 
   *  e.g.  400 -> 0,  500 -> 1,  502 -> 2 ...                     
   * the indicies have no significance
   */
  
! char *status_lines[] = {
     "200 OK",
     "206 Partial Content",
     "300 Multiple Choices",
!    "301 Moved Permanently",
!    "302 Found",
     "304 Not Modified",
     "400 Bad Request",
!    "401 Unauthorized",
     "403 Forbidden",
!    "404 Not found",
     "405 Method Not Allowed",
     "406 Not Acceptable",
     "411 Length Required",
     "412 Precondition Failed",
     "500 Server error",
!    "503 Out of resources",
!    "501 Not Implemented",
     "502 Bad Gateway",
     "506 Variant Also Varies"
  }; 
  
- char *response_titles[] = {
-    "200 OK",			/* Never actually sent, barring die(200,...) */
-    "206 Partial Content",	/* Never sent as an error (we hope) */
-    "Multiple Choices",		/* 300 Multiple Choices */
-    "Document moved",		/* 301 Redirect */
-    "Document moved",		/* 302 Redirect */
-    "304 Not Modified",		/* Never sent... 304 MUST be header only */
-    "Bad Request",
-    "Authorization Required",
-    "Forbidden",
-    "File Not found",
-    "Method Not Allowed",
-    "Not Acceptable",
-    "Length Required",
-    "Precondition Failed",
-    "Server Error",
-    "Out of resources",
-    "Method not implemented",
-    "Bad Gateway",
-    "Variant Also Varies"
- };
- 
  int index_of_response(int err_no) {
!    char *cptr, err_string[10];
!    static char *response_codes = RESPONSE_CODE_LIST;
     int index_number;
!    
     sprintf(err_string,"%3d",err_no);
!    
!    cptr = response_codes;
!    cptr++;
!    index_number = 0;
!    while (*cptr && strncmp(cptr, err_string, 3)) { 
!       cptr += 4;
!       index_number++;
     }
!    if (!*cptr) return -1;
!    return index_number;
  }
  
  
  void basic_http_header (request_rec *r)
  {
--- 789,856 ----
      *pw = t;
  
      return OK;
  }
  
  /* New Apache routine to map error responses into array indicies 
   *  e.g.  400 -> 0,  500 -> 1,  502 -> 2 ...                     
   * the indicies have no significance
   */
  
! static char *status_lines[] = {
!    "100 Continue",
!    "101 Switching Protocols",
     "200 OK",
+    "201 Created",
+    "202 Accepted",
+    "203 Non-Authoritative Information",
+    "204 No Content",
+    "205 Reset Content",
     "206 Partial Content",
     "300 Multiple Choices",
!    "301 Document Moved Permanently",
!    "302 Document Moved Temporarily",
!    "303 See Other",
     "304 Not Modified",
+    "305 Use Proxy",
     "400 Bad Request",
!    "401 Authorization Required",
!    "402 Payment Required",
     "403 Forbidden",
!    "404 File Not Found",
     "405 Method Not Allowed",
     "406 Not Acceptable",
+    "407 Proxy Authentication Required",
+    "408 Request Time-out",
+    "409 Conflict",
+    "410 Gone",
     "411 Length Required",
     "412 Precondition Failed",
+    "413 Request Entity Too Large",
+    "414 Request-URI Too Large",
+    "415 Unsupported Media Type",
     "500 Server error",
!    "501 Method Not Implemented",
     "502 Bad Gateway",
+    "503 Out of resources",
+    "504 Gateway Time-out",
+    "505 HTTP Version not supported",
     "506 Variant Also Varies"
  }; 
  
  int index_of_response(int err_no) {
!    char err_string[10];
     int index_number;
! 
     sprintf(err_string,"%3d",err_no);
! 
!    for (index_number = 0; index_number < RESPONSE_CODES; ++index_number) {
!        if (!strncmp(status_lines[index_number], err_string, 3)) {
! 	   return index_number;
!        }
     }
!    return -1;
  }
  
  
  void basic_http_header (request_rec *r)
  {
***************
*** 1325,1335 ****
  	 */
  	while (r->prev && r->prev->status != 200)
            r = r->prev;
      }
      {
! 	char *title = response_titles[idx];
  	BUFF *fd = c->client;
  	
          bvputs(fd,"<HEAD><TITLE>", title, "</TITLE></HEAD>\n<BODY><H1>",
title,
  	       "</H1>\n", NULL);
  	
--- 1316,1327 ----
  	 */
  	while (r->prev && r->prev->status != 200)
            r = r->prev;
      }
      {
!         /* Magic number "4" is length of a response code and a space.  */
! 	char *title = status_lines[idx] + 4;
  	BUFF *fd = c->client;
  	
          bvputs(fd,"<HEAD><TITLE>", title, "</TITLE></HEAD>\n<BODY><H1>",
title,
  	       "</H1>\n", NULL);
  	
Index: httpd.h
===================================================================
RCS file: /export/home/cvs/apache/src/httpd.h,v
retrieving revision 1.51
diff -c -5 -r1.51 httpd.h
*** httpd.h	1996/09/30 05:56:26	1.51
--- httpd.h	1996/10/01 19:58:31
***************
*** 270,280 ****
  #define SERVER_ERROR 500
  #define NOT_IMPLEMENTED 501
  #define BAD_GATEWAY 502
  #define HTTP_SERVICE_UNAVAILABLE 503
  #define VARIANT_ALSO_VARIES 506
! #define RESPONSE_CODES 18
  
  #define METHODS 8
  #define M_GET 0
  #define M_PUT 1
  #define M_POST 2
--- 270,280 ----
  #define SERVER_ERROR 500
  #define NOT_IMPLEMENTED 501
  #define BAD_GATEWAY 502
  #define HTTP_SERVICE_UNAVAILABLE 503
  #define VARIANT_ALSO_VARIES 506
! #define RESPONSE_CODES 38
  
  #define METHODS 8
  #define M_GET 0
  #define M_PUT 1
  #define M_POST 2

Mime
View raw message