Mercurial > hg > nginx-quic
view src/http/ngx_http_header_filter.c @ 10:4f3879d9b6f6
nginx-0.0.1-2002-09-11-19:18:33 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 11 Sep 2002 15:18:33 +0000 |
parents | src/http/modules/ngx_http_header_filter.c@708f8bb772ec |
children | 2aba961a1d34 |
line wrap: on
line source
#include <nginx.h> #include <ngx_config.h> #include <ngx_core.h> #include <ngx_string.h> #include <ngx_hunk.h> #include <ngx_http.h> typedef struct { int len; char *line; } line; static line http_codes[] = { { 6, "200 OK" } }; int ngx_http_header_filter(ngx_http_request_t *r) { int status; ngx_hunk_t *h; ngx_chain_t *ch; ngx_test_null(h, ngx_create_temp_hunk(r->pool, 1024, 0, 64), NGX_ERROR); status = r->headers_out->status - NGX_HTTP_OK; ngx_memcpy(h->last.mem, "HTTP/1.0 ", 9); h->last.mem += 9; ngx_memcpy(h->last.mem, http_codes[status].line, http_codes[status].len); h->last.mem += http_codes[status].len; *(h->last.mem++) = CR; *(h->last.mem++) = LF; /* 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; */ /* 2^64 is 20 characters */ if (r->headers_out->content_length) h->last.mem += ngx_snprintf(h->last.mem, 49, "Content-Length: %d" CRLF, r->headers_out->content_length); /* check */ memcpy(h->last.mem, "Server: ", 8); h->last.mem += 8; if (r->headers_out->server) { h->last.mem = ngx_cpystrn(h->last.mem, r->headers_out->server, h->end - h->last.mem); /* check space */ } else { ngx_memcpy(h->last.mem, NGINX_VER, sizeof(NGINX_VER)); h->last.mem += sizeof(NGINX_VER); } *(h->last.mem++) = CR; *(h->last.mem++) = LF; /* end of HTTP header */ *(h->last.mem++) = CR; *(h->last.mem++) = LF; ngx_test_null(ch, ngx_palloc(r->pool, sizeof(ngx_chain_t)), /* STUB */ -1); /* NGX_HTTP_FILTER_ERROR); */ ch->hunk = h; ch->next = NULL; return ngx_http_write_filter(r, ch); }