diff src/http/ngx_http_header_filter.c @ 67:5a7d1aaa1618

nginx-0.0.1-2003-03-11-23:38:13 import
author Igor Sysoev <igor@sysoev.ru>
date Tue, 11 Mar 2003 20:38:13 +0000
parents 34d647deb1da
children e43f406e4525
line wrap: on
line diff
--- a/src/http/ngx_http_header_filter.c
+++ b/src/http/ngx_http_header_filter.c
@@ -48,22 +48,37 @@ static char server_string[] = "Server: "
 static ngx_str_t http_codes[] = {
 
     ngx_string("200 OK"),
-#if 0
-    { 6,  "200 OK" },
-#endif
+
+    ngx_string("301 Moved Permanently"),
+    ngx_string("302 Moved Temporarily"),
+    ngx_null_string,  /* 303 */
+    ngx_string("304 Not Modified"),
 
-    { 21, "301 Moved Permanently" },
-    { 21, "302 Moved Temporarily" },
-    { 0,  NULL },
-    { 16, "304 Not Modified" },
+    ngx_string("400 Bad Request"),
+    ngx_null_string,  /* 401 */
+    ngx_null_string,  /* 402 */
+    ngx_string("403 Forbidden"),
+    ngx_string("404 Not Found"),
+    ngx_null_string,  /* 405 */
+    ngx_null_string,  /* 406 */
+    ngx_null_string,  /* 407 */
+    ngx_string("408 Request Time-out"),
+    ngx_null_string,  /* 409 */
+    ngx_null_string,  /* 410 */
+    ngx_string("411 Length Required"),
+    ngx_null_string,  /* 412 */
+    ngx_string("413 Request Entity Too Large"),
+    ngx_null_string,  /* "414 Request-URI Too Large" but we never send it
+                         because we treat such requests as HTTP/0.9 requests
+                         and send only the body without the header */
+    ngx_null_string,  /* 415 */
+    ngx_string("416 Requested Range Not Satisfiable"),
 
-    { 15, "400 Bad Request" },
-    { 0,  NULL },
-    { 0,  NULL },
-    { 13, "403 Forbidden" },
-    { 13, "404 Not Found" },
-
-    { 25, "500 Internal Server Error" }
+    ngx_string("500 Internal Server Error"),
+    ngx_string("501 Method Not Implemented"),
+    ngx_string("502 Bad Gateway"),
+    ngx_string("503 Service Temporarily Unavailable"),
+    ngx_string("504 Gateway Time-out")
 };
 
 
@@ -124,7 +139,7 @@ static int ngx_http_header_filter(ngx_ht
 
         } else {
             status = r->headers_out.status
-                                 - NGX_HTTP_INTERNAL_SERVER_ERROR + 1 + 4 + 5;
+                                 - NGX_HTTP_INTERNAL_SERVER_ERROR + 1 + 4 + 17;
         }
 
         len += http_codes[status].len;
@@ -181,49 +196,49 @@ static int ngx_http_header_filter(ngx_ht
     ngx_test_null(h, ngx_create_temp_hunk(r->pool, len, 0, 64), NGX_ERROR);
 
     /* "HTTP/1.x " */
-    ngx_memcpy(h->last.mem, "HTTP/1.1 ", 9);
-    h->last.mem += 9;
+    ngx_memcpy(h->last, "HTTP/1.1 ", 9);
+    h->last += 9;
 
     /* status line */
     if (r->headers_out.status_line.len) {
-        ngx_memcpy(h->last.mem, r->headers_out.status_line.data,
+        ngx_memcpy(h->last, r->headers_out.status_line.data,
                    r->headers_out.status_line.len);
-        h->last.mem += r->headers_out.status_line.len;
+        h->last += r->headers_out.status_line.len;
 
     } else {
-        ngx_memcpy(h->last.mem, http_codes[status].data,
+        ngx_memcpy(h->last, http_codes[status].data,
                    http_codes[status].len);
-        h->last.mem += http_codes[status].len;
+        h->last += http_codes[status].len;
     }
-    *(h->last.mem++) = CR; *(h->last.mem++) = LF;
+    *(h->last++) = CR; *(h->last++) = LF;
 
     if (!(r->headers_out.server && r->headers_out.server->key.len)) {
-        ngx_memcpy(h->last.mem, server_string, sizeof(server_string) - 1);
-        h->last.mem += sizeof(server_string) - 1;
+        ngx_memcpy(h->last, server_string, sizeof(server_string) - 1);
+        h->last += sizeof(server_string) - 1;
     }
 
     if (!(r->headers_out.date && r->headers_out.date->key.len)) {
-        ngx_memcpy(h->last.mem, "Date: ", 6);
-        h->last.mem += 6;
-        h->last.mem += ngx_http_get_time(h->last.mem, time(NULL));
-        *(h->last.mem++) = CR; *(h->last.mem++) = LF;
+        ngx_memcpy(h->last, "Date: ", 6);
+        h->last += 6;
+        h->last += ngx_http_get_time(h->last, time(NULL));
+        *(h->last++) = CR; *(h->last++) = LF;
     }
 
     /* 2^64 is 20 characters  */
     if (r->headers_out.content_length >= 0) {
-        h->last.mem += ngx_snprintf(h->last.mem, 49,
+        h->last += ngx_snprintf(h->last, 49,
                                     "Content-Length: " OFF_FMT CRLF,
                                     r->headers_out.content_length);
     }
 
 #if 0
     if (r->headers_out.content_type.len) {
-        ngx_memcpy(h->last.mem, "Content-Type: ", 14);
-        h->last.mem += 14;
-        ngx_memcpy(h->last.mem, r->headers_out.content_type.data,
+        ngx_memcpy(h->last, "Content-Type: ", 14);
+        h->last += 14;
+        ngx_memcpy(h->last, r->headers_out.content_type.data,
                    r->headers_out.content_type.len);
-        h->last.mem += r->headers_out.content_type.len;
-        *(h->last.mem++) = CR; *(h->last.mem++) = LF;
+        h->last += r->headers_out.content_type.len;
+        *(h->last++) = CR; *(h->last++) = LF;
     }
 #endif
 
@@ -231,20 +246,20 @@ static int ngx_http_header_filter(ngx_ht
           && r->headers_out.last_modified->key.len)
         && r->headers_out.last_modified_time != -1)
     {
-        ngx_memcpy(h->last.mem, "Last-Modified: ", 15);
-        h->last.mem += 15;
-        h->last.mem += ngx_http_get_time(h->last.mem,
+        ngx_memcpy(h->last, "Last-Modified: ", 15);
+        h->last += 15;
+        h->last += ngx_http_get_time(h->last,
                                          r->headers_out.last_modified_time);
-        *(h->last.mem++) = CR; *(h->last.mem++) = LF;
+        *(h->last++) = CR; *(h->last++) = LF;
     }
 
     if (r->keepalive == 0) {
-        ngx_memcpy(h->last.mem, "Connection: close" CRLF, 19);
-        h->last.mem += 19;
+        ngx_memcpy(h->last, "Connection: close" CRLF, 19);
+        h->last += 19;
 
     } else {
-        ngx_memcpy(h->last.mem, "Connection: keep-alive" CRLF, 24);
-        h->last.mem += 24;
+        ngx_memcpy(h->last, "Connection: keep-alive" CRLF, 24);
+        h->last += 24;
     }
 
     for (i = 0; i < r->headers_out.headers->nelts; i++) {
@@ -252,22 +267,22 @@ static int ngx_http_header_filter(ngx_ht
             continue;
         }
 
-        ngx_memcpy(h->last.mem, header[i].key.data, header[i].key.len);
-        h->last.mem += header[i].key.len;
-        *(h->last.mem++) = ':' ; *(h->last.mem++) = ' ' ;
+        ngx_memcpy(h->last, header[i].key.data, header[i].key.len);
+        h->last += header[i].key.len;
+        *(h->last++) = ':' ; *(h->last++) = ' ' ;
 
-        ngx_memcpy(h->last.mem, header[i].value.data, header[i].value.len);
-        h->last.mem += header[i].value.len;
-        *(h->last.mem++) = CR; *(h->last.mem++) = LF;
+        ngx_memcpy(h->last, header[i].value.data, header[i].value.len);
+        h->last += header[i].value.len;
+        *(h->last++) = CR; *(h->last++) = LF;
     }
 
     /* STUB */
-    *(h->last.mem) = '\0';
-    ngx_log_debug(r->connection->log, "%s\n" _ h->pos.mem);
+    *(h->last) = '\0';
+    ngx_log_debug(r->connection->log, "%s\n" _ h->pos);
     /**/
 
     /* end of HTTP header */
-    *(h->last.mem++) = CR; *(h->last.mem++) = LF;
+    *(h->last++) = CR; *(h->last++) = LF;
 
     if (r->header_only) {
         h->type |= NGX_HUNK_LAST;