comparison src/http/ngx_http_header_filter.c @ 13:2aba961a1d34

nginx-0.0.1-2002-09-16-19:01:44 import
author Igor Sysoev <igor@sysoev.ru>
date Mon, 16 Sep 2002 15:01:44 +0000
parents 4f3879d9b6f6
children d7908993fdeb
comparison
equal deleted inserted replaced
12:055ed05235ae 13:2aba961a1d34
29 ngx_test_null(h, ngx_create_temp_hunk(r->pool, 1024, 0, 64), 29 ngx_test_null(h, ngx_create_temp_hunk(r->pool, 1024, 0, 64),
30 NGX_ERROR); 30 NGX_ERROR);
31 31
32 status = r->headers_out->status - NGX_HTTP_OK; 32 status = r->headers_out->status - NGX_HTTP_OK;
33 33
34 ngx_memcpy(h->last.mem, "HTTP/1.0 ", 9); 34 ngx_memcpy(h->last.mem, "HTTP/1.1 ", 9);
35 h->last.mem += 9; 35 h->last.mem += 9;
36 ngx_memcpy(h->last.mem, http_codes[status].line, http_codes[status].len); 36 ngx_memcpy(h->last.mem, http_codes[status].line, http_codes[status].len);
37 h->last.mem += http_codes[status].len; 37 h->last.mem += http_codes[status].len;
38 *(h->last.mem++) = CR; *(h->last.mem++) = LF; 38 *(h->last.mem++) = CR; *(h->last.mem++) = LF;
39 39
40 #if 1
41 r->keepalive = 1;
42 ngx_memcpy(h->last.mem, "Connection: keep-alive" CRLF, 24);
43 h->last.mem += 24;
44 #endif
45
40 /* 46 /*
41 memcpy(h->last.mem, "Date: ", 6); 47 ngx_memcpy(h->last.mem, "Date: ", 6);
42 h->last.mem += 6; 48 h->last.mem += 6;
43 h->last.mem += ngx_http_get_time(h->last.mem, time(NULL)); 49 h->last.mem += ngx_http_get_time(h->last.mem, time(NULL));
44 *(h->last.mem++) = CR; *(h->last.mem++) = LF; 50 *(h->last.mem++) = CR; *(h->last.mem++) = LF;
45 */ 51 */
46 52
49 h->last.mem += ngx_snprintf(h->last.mem, 49, "Content-Length: %d" CRLF, 55 h->last.mem += ngx_snprintf(h->last.mem, 49, "Content-Length: %d" CRLF,
50 r->headers_out->content_length); 56 r->headers_out->content_length);
51 57
52 /* check */ 58 /* check */
53 59
54 memcpy(h->last.mem, "Server: ", 8); 60 if (r->headers_out->content_type)
61 h->last.mem += ngx_snprintf(h->last.mem, 100, "Content-Type: %s" CRLF,
62 r->headers_out->content_type);
63
64 ngx_memcpy(h->last.mem, "Server: ", 8);
55 h->last.mem += 8; 65 h->last.mem += 8;
56 if (r->headers_out->server) { 66 if (r->headers_out->server) {
57 h->last.mem = ngx_cpystrn(h->last.mem, r->headers_out->server, 67 h->last.mem = ngx_cpystrn(h->last.mem, r->headers_out->server,
58 h->end - h->last.mem); 68 h->end - h->last.mem);
59
60 /* check space */ 69 /* check space */
61 70
62 } else { 71 } else {
63 ngx_memcpy(h->last.mem, NGINX_VER, sizeof(NGINX_VER)); 72 ngx_memcpy(h->last.mem, NGINX_VER, sizeof(NGINX_VER) - 1);
64 h->last.mem += sizeof(NGINX_VER); 73 h->last.mem += sizeof(NGINX_VER) - 1;
65 } 74 }
66 *(h->last.mem++) = CR; *(h->last.mem++) = LF; 75 *(h->last.mem++) = CR; *(h->last.mem++) = LF;
67 76
68 /* end of HTTP header */ 77 /* end of HTTP header */
69 *(h->last.mem++) = CR; *(h->last.mem++) = LF; 78 *(h->last.mem++) = CR; *(h->last.mem++) = LF;