mirror of
https://github.com/nginx/nginx.git
synced 2024-12-20 06:03:31 -06:00
nginx-0.0.3-2004-03-23-09:01:52 import
This commit is contained in:
parent
ae02c19867
commit
89690bfe02
@ -92,7 +92,7 @@ typedef struct {
|
||||
ngx_hunk_tag_t tag;
|
||||
|
||||
ngx_output_chain_filter_pt output_filter;
|
||||
void *output_ctx;
|
||||
void *filter_ctx;
|
||||
} ngx_output_chain_ctx_t;
|
||||
|
||||
|
||||
|
@ -28,13 +28,13 @@ int ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
|
||||
if (ctx->in == NULL) {
|
||||
|
||||
if (in == NULL) {
|
||||
return ctx->output_filter(ctx->output_ctx, in);
|
||||
return ctx->output_filter(ctx->filter_ctx, in);
|
||||
}
|
||||
|
||||
if (in->next == NULL
|
||||
&& (!ngx_output_chain_need_to_copy(ctx, in->hunk)))
|
||||
{
|
||||
return ctx->output_filter(ctx->output_ctx, in);
|
||||
return ctx->output_filter(ctx->filter_ctx, in);
|
||||
}
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ int ngx_output_chain(ngx_output_chain_ctx_t *ctx, ngx_chain_t *in)
|
||||
return last;
|
||||
}
|
||||
|
||||
last = ctx->output_filter(ctx->output_ctx, out);
|
||||
last = ctx->output_filter(ctx->filter_ctx, out);
|
||||
|
||||
ngx_chain_update_chains(&ctx->free, &ctx->busy, &out, ctx->tag);
|
||||
last_out = &out;
|
||||
|
@ -42,6 +42,10 @@ ngx_regex_t *ngx_regex_compile(ngx_str_t *pattern, ngx_int_t options,
|
||||
}
|
||||
}
|
||||
|
||||
/* ensure that there is no current pool */
|
||||
|
||||
ngx_pcre_pool = NULL;
|
||||
|
||||
return re;
|
||||
}
|
||||
|
||||
@ -64,7 +68,11 @@ ngx_int_t ngx_regex_exec(ngx_regex_t *re, ngx_str_t *s,
|
||||
|
||||
static void *ngx_regex_malloc(size_t size)
|
||||
{
|
||||
return ngx_palloc(ngx_pcre_pool, size);
|
||||
if (ngx_pcre_pool) {
|
||||
return ngx_palloc(ngx_pcre_pool, size);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -377,12 +377,16 @@ int ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
|
||||
bsize = 0;
|
||||
to_write = 0;
|
||||
|
||||
#if 0
|
||||
if (!(p->upstream_eof || p->upstream_error || p->upstream_done)) {
|
||||
#endif
|
||||
for (cl = p->busy; cl; cl = cl->next) {
|
||||
bsize += cl->hunk->end - cl->hunk->start;
|
||||
to_write += ngx_hunk_size(cl->hunk);
|
||||
}
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
|
||||
out = NULL;
|
||||
ll = NULL;
|
||||
@ -391,11 +395,17 @@ int ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
|
||||
if (p->out) {
|
||||
cl = p->out;
|
||||
|
||||
#if 0
|
||||
if (!(p->upstream_eof || p->upstream_error || p->upstream_done)
|
||||
&& (bsize + ngx_hunk_size(cl->hunk) > p->busy_size))
|
||||
{
|
||||
break;
|
||||
}
|
||||
#else
|
||||
if (bsize + ngx_hunk_size(cl->hunk) > p->busy_size) {
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
p->out = p->out->next;
|
||||
ngx_event_pipe_free_shadow_raw_hunk(&p->free_raw_hunks,
|
||||
@ -404,11 +414,17 @@ int ngx_event_pipe_write_to_downstream(ngx_event_pipe_t *p)
|
||||
} else if (!p->cachable && p->in) {
|
||||
cl = p->in;
|
||||
|
||||
#if 0
|
||||
if (!(p->upstream_eof || p->upstream_error || p->upstream_done)
|
||||
&& (bsize + ngx_hunk_size(cl->hunk) > p->busy_size))
|
||||
{
|
||||
break;
|
||||
}
|
||||
#else
|
||||
if (bsize + ngx_hunk_size(cl->hunk) > p->busy_size) {
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
p->in = p->in->next;
|
||||
|
||||
|
@ -32,7 +32,7 @@ typedef struct {
|
||||
|
||||
void *preallocated;
|
||||
char *free_mem;
|
||||
int allocated;
|
||||
ngx_uint_t allocated;
|
||||
|
||||
unsigned flush:4;
|
||||
unsigned redo:1;
|
||||
@ -515,8 +515,8 @@ static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, u_int size)
|
||||
{
|
||||
ngx_http_gzip_ctx_t *ctx = opaque;
|
||||
|
||||
int alloc;
|
||||
void *p;
|
||||
void *p;
|
||||
ngx_uint_t alloc;
|
||||
|
||||
alloc = items * size;
|
||||
if (alloc % 512 != 0) {
|
||||
@ -533,7 +533,7 @@ static void *ngx_http_gzip_filter_alloc(void *opaque, u_int items, u_int size)
|
||||
ctx->allocated -= alloc;
|
||||
|
||||
ngx_log_debug4(NGX_LOG_DEBUG_HTTP, ctx->request->connection->log, 0,
|
||||
"gzip alloc: n:%d s:%d a:%d p:%08X",
|
||||
"gzip alloc: n:%d s:%d a:%d p:" PTR_FMT,
|
||||
items, size, alloc, p);
|
||||
|
||||
return p;
|
||||
|
@ -89,7 +89,7 @@ static ngx_int_t ngx_http_static_handler(ngx_http_request_t *r)
|
||||
|
||||
rc = ngx_http_discard_body(r);
|
||||
|
||||
if (rc != NGX_OK) {
|
||||
if (rc != NGX_OK && rc != NGX_AGAIN) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ typedef struct {
|
||||
|
||||
|
||||
typedef struct {
|
||||
ngx_table_t *headers; /* it must be first field */
|
||||
ngx_table_t headers; /* it must be first field */
|
||||
|
||||
ngx_table_elt_t *date;
|
||||
ngx_table_elt_t *server;
|
||||
|
@ -17,8 +17,8 @@ int ngx_http_proxy_copy_header(ngx_http_proxy_ctx_t *p,
|
||||
|
||||
r = p->request;
|
||||
|
||||
h = headers_in->headers->elts;
|
||||
for (i = 0; i < headers_in->headers->nelts; i++) {
|
||||
h = headers_in->headers.elts;
|
||||
for (i = 0; i < headers_in->headers.nelts; i++) {
|
||||
|
||||
if (&h[i] == headers_in->connection) {
|
||||
continue;
|
||||
@ -98,37 +98,43 @@ static int ngx_http_proxy_rewrite_location_header(ngx_http_proxy_ctx_t *p,
|
||||
ngx_table_elt_t *loc)
|
||||
{
|
||||
u_char *last;
|
||||
ngx_table_elt_t *location;
|
||||
ngx_http_request_t *r;
|
||||
ngx_http_proxy_upstream_conf_t *uc;
|
||||
|
||||
r = p->request;
|
||||
uc = p->lcf->upstream;
|
||||
|
||||
r->headers_out.location = ngx_http_add_header(&r->headers_out,
|
||||
ngx_http_headers_out);
|
||||
if (r->headers_out.location == NULL) {
|
||||
location = ngx_http_add_header(&r->headers_out, ngx_http_headers_out);
|
||||
if (location == NULL) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* we do not set r->headers_out.location to avoid the handling
|
||||
* the local redirects without a host name by ngx_http_header_filter()
|
||||
*/
|
||||
|
||||
#if 0
|
||||
r->headers_out.location = location;
|
||||
#endif
|
||||
|
||||
if (uc->url.len > loc->value.len
|
||||
|| ngx_rstrncmp(loc->value.data, uc->url.data, uc->url.len) != 0)
|
||||
{
|
||||
*r->headers_out.location = *loc;
|
||||
*location = *loc;
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
/* TODO: proxy_reverse */
|
||||
|
||||
r->headers_out.location->value.len = uc->location->len
|
||||
+ (loc->value.len - uc->url.len) + 1;
|
||||
r->headers_out.location->value.data =
|
||||
ngx_palloc(r->pool, r->headers_out.location->value.len);
|
||||
|
||||
if (r->headers_out.location->value.data == NULL) {
|
||||
location->value.len = uc->location->len
|
||||
+ (loc->value.len - uc->url.len) + 1;
|
||||
if (!(location->value.data = ngx_palloc(r->pool, location->value.len))) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
last = ngx_cpymem(r->headers_out.location->value.data,
|
||||
last = ngx_cpymem(location->value.data,
|
||||
uc->location->data, uc->location->len);
|
||||
|
||||
ngx_cpystrn(last, loc->value.data + uc->url.len,
|
||||
|
@ -148,8 +148,8 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
|
||||
}
|
||||
|
||||
|
||||
header = (ngx_table_elt_t *) r->headers_in.headers->elts;
|
||||
for (i = 0; i < r->headers_in.headers->nelts; i++) {
|
||||
header = r->headers_in.headers.elts;
|
||||
for (i = 0; i < r->headers_in.headers.nelts; i++) {
|
||||
|
||||
if (&header[i] == r->headers_in.host) {
|
||||
continue;
|
||||
@ -198,7 +198,7 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
|
||||
|
||||
h->last = ngx_cpymem(h->last, host_header, sizeof(host_header) - 1);
|
||||
|
||||
if (p->lcf->preserve_host) {
|
||||
if (p->lcf->preserve_host && r->headers_in.host) {
|
||||
h->last = ngx_cpymem(h->last, r->headers_in.host->value.data,
|
||||
r->headers_in.host_name_len);
|
||||
|
||||
@ -250,7 +250,7 @@ static ngx_chain_t *ngx_http_proxy_create_request(ngx_http_proxy_ctx_t *p)
|
||||
}
|
||||
|
||||
|
||||
for (i = 0; i < r->headers_in.headers->nelts; i++) {
|
||||
for (i = 0; i < r->headers_in.headers.nelts; i++) {
|
||||
|
||||
if (&header[i] == r->headers_in.host) {
|
||||
continue;
|
||||
@ -377,7 +377,7 @@ static void ngx_http_proxy_init_upstream(void *data)
|
||||
return;
|
||||
}
|
||||
|
||||
output->output_ctx = writer;
|
||||
output->filter_ctx = writer;
|
||||
writer->pool = r->pool;
|
||||
|
||||
if (p->lcf->busy_lock && !p->busy_locked) {
|
||||
@ -392,7 +392,6 @@ static void ngx_http_proxy_reinit_upstream(ngx_http_proxy_ctx_t *p)
|
||||
{
|
||||
ngx_chain_t *cl;
|
||||
ngx_output_chain_ctx_t *output;
|
||||
ngx_chain_writer_ctx_t *writer;
|
||||
|
||||
output = p->upstream->output_chain_ctx;
|
||||
|
||||
@ -400,6 +399,7 @@ static void ngx_http_proxy_reinit_upstream(ngx_http_proxy_ctx_t *p)
|
||||
|
||||
for (cl = p->request->request_hunks; cl; cl = cl->next) {
|
||||
cl->hunk->pos = cl->hunk->start;
|
||||
cl->hunk->file_pos = 0;
|
||||
}
|
||||
|
||||
/* reinit the ngx_output_chain() context */
|
||||
@ -521,7 +521,7 @@ static void ngx_http_proxy_connect(ngx_http_proxy_ctx_t *p)
|
||||
/* init or reinit the ngx_output_chain() and ngx_chain_writer() contexts */
|
||||
|
||||
output = p->upstream->output_chain_ctx;
|
||||
writer = output->output_ctx;
|
||||
writer = output->filter_ctx;
|
||||
writer->out = NULL;
|
||||
writer->last = &writer->out;
|
||||
writer->connection = c;
|
||||
@ -541,7 +541,6 @@ static void ngx_http_proxy_connect(ngx_http_proxy_ctx_t *p)
|
||||
output->hunks = 1;
|
||||
|
||||
r->request_body_hunk->pos = r->request_body_hunk->start;
|
||||
r->request_body_hunk->last = r->request_body_hunk->start;
|
||||
}
|
||||
|
||||
p->request_sent = 0;
|
||||
@ -824,14 +823,26 @@ static void ngx_http_proxy_process_upstream_status_line(ngx_event_t *rev)
|
||||
"http proxy status %d \"%s\"",
|
||||
p->upstream->status, p->upstream->status_line.data);
|
||||
|
||||
if (p->upstream->headers_in.headers) {
|
||||
p->upstream->headers_in.headers->nelts = 0;
|
||||
|
||||
/* init or reinit the p->upstream->headers_in.headers table */
|
||||
|
||||
if (p->upstream->headers_in.headers.elts) {
|
||||
p->upstream->headers_in.headers.nelts = 0;
|
||||
|
||||
} else {
|
||||
/* TODO: ngx_init_table */
|
||||
p->upstream->headers_in.headers = ngx_create_table(p->request->pool,
|
||||
20);
|
||||
p->upstream->headers_in.headers.elts = ngx_pcalloc(p->request->pool,
|
||||
20 * sizeof(ngx_table_elt_t));
|
||||
if (p->upstream->headers_in.headers.elts == NULL) {
|
||||
ngx_http_proxy_finalize_request(p, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||
return;
|
||||
}
|
||||
/* p->upstream->headers_in.headers.nelts = 0; */
|
||||
p->upstream->headers_in.headers.nalloc = 20;
|
||||
p->upstream->headers_in.headers.size = sizeof(ngx_table_elt_t);
|
||||
p->upstream->headers_in.headers.pool = p->request->pool;
|
||||
}
|
||||
|
||||
|
||||
c->read->event_handler = ngx_http_proxy_process_upstream_headers;
|
||||
ngx_http_proxy_process_upstream_headers(rev);
|
||||
}
|
||||
|
@ -537,6 +537,25 @@ int ngx_http_find_location_config(ngx_http_request_t *r)
|
||||
r->connection->tcp_nopush = -1;
|
||||
}
|
||||
|
||||
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"http cl: " SIZE_T_FMT " max: " SIZE_T_FMT,
|
||||
r->headers_in.content_length_n,
|
||||
clcf->client_max_body_size);
|
||||
|
||||
if (r->headers_in.content_length_n != -1
|
||||
&& clcf->client_max_body_size
|
||||
&& clcf->client_max_body_size < (size_t) r->headers_in.content_length_n)
|
||||
{
|
||||
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
||||
"client intented to send too large body: "
|
||||
SIZE_T_FMT " bytes",
|
||||
r->headers_in.content_length_n);
|
||||
|
||||
return NGX_HTTP_REQUEST_ENTITY_TOO_LARGE;
|
||||
}
|
||||
|
||||
|
||||
if (auto_redirect) {
|
||||
if (!(r->headers_out.location =
|
||||
ngx_http_add_header(&r->headers_out, ngx_http_headers_out)))
|
||||
|
@ -205,8 +205,8 @@ static int ngx_http_header_filter(ngx_http_request_t *r)
|
||||
len += sizeof("Connection: closed" CRLF) - 1;
|
||||
}
|
||||
|
||||
header = r->headers_out.headers->elts;
|
||||
for (i = 0; i < r->headers_out.headers->nelts; i++) {
|
||||
header = r->headers_out.headers.elts;
|
||||
for (i = 0; i < r->headers_out.headers.nelts; i++) {
|
||||
if (header[i].key.len == 0) {
|
||||
continue;
|
||||
}
|
||||
@ -321,7 +321,7 @@ static int ngx_http_header_filter(ngx_http_request_t *r)
|
||||
sizeof("Connection: close" CRLF) - 1);
|
||||
}
|
||||
|
||||
for (i = 0; i < r->headers_out.headers->nelts; i++) {
|
||||
for (i = 0; i < r->headers_out.headers.nelts; i++) {
|
||||
if (header[i].key.len == 0) {
|
||||
continue;
|
||||
}
|
||||
|
@ -60,12 +60,12 @@ ngx_http_header_t ngx_http_headers_out[] = {
|
||||
ngx_table_elt_t *ngx_http_add_header(void *header,
|
||||
ngx_http_header_t *http_headers)
|
||||
{
|
||||
char *prev;
|
||||
void *prev;
|
||||
ngx_uint_t i, j;
|
||||
ngx_table_t *headers;
|
||||
ngx_table_elt_t *h, *new;
|
||||
|
||||
headers = *(ngx_table_t **) header;
|
||||
headers = header;
|
||||
|
||||
prev = headers->elts;
|
||||
|
||||
|
@ -327,8 +327,8 @@ static u_char *ngx_http_log_unknown_header_in(ngx_http_request_t *r,
|
||||
|
||||
s = (ngx_str_t *) data;
|
||||
|
||||
h = r->headers_in.headers->elts;
|
||||
for (i = 0; i < r->headers_in.headers->nelts; i++) {
|
||||
h = r->headers_in.headers.elts;
|
||||
for (i = 0; i < r->headers_in.headers.nelts; i++) {
|
||||
if (h[i].key.len != s->len) {
|
||||
continue;
|
||||
}
|
||||
@ -535,8 +535,8 @@ static u_char *ngx_http_log_unknown_header_out(ngx_http_request_t *r,
|
||||
|
||||
s = (ngx_str_t *) data;
|
||||
|
||||
h = r->headers_out.headers->elts;
|
||||
for (i = 0; i < r->headers_out.headers->nelts; i++) {
|
||||
h = r->headers_out.headers.elts;
|
||||
for (i = 0; i < r->headers_out.headers.nelts; i++) {
|
||||
if (h[i].key.len != s->len) {
|
||||
continue;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ int ngx_http_output_filter(ngx_http_request_t *r, ngx_chain_t *in)
|
||||
|
||||
ctx->output_filter = (ngx_output_chain_filter_pt)
|
||||
ngx_http_top_body_filter;
|
||||
ctx->output_ctx = r;
|
||||
ctx->filter_ctx = r;
|
||||
|
||||
}
|
||||
|
||||
|
@ -38,8 +38,7 @@ static char *client_header_errors[] = {
|
||||
"client %s sent invalid header, URL: %s",
|
||||
"client %s sent too long header line, URL: %s",
|
||||
"client %s sent HTTP/1.1 request without \"Host\" header, URL: %s",
|
||||
"client %s sent invalid \"Content-Length\" header, URL: %s",
|
||||
"client %s wanted to send too large body: " SIZE_T_FMT " bytes, URL: %s"
|
||||
"client %s sent invalid \"Content-Length\" header, URL: %s"
|
||||
};
|
||||
|
||||
|
||||
@ -248,12 +247,21 @@ static void ngx_http_init_request(ngx_event_t *rev)
|
||||
r->cleanup.size = sizeof(ngx_http_cleanup_t);
|
||||
r->cleanup.pool = r->pool;
|
||||
|
||||
/* TODO: ngx_init_table */
|
||||
if (!(r->headers_out.headers = ngx_create_table(r->pool, 20))) {
|
||||
|
||||
/* init the r->headers_out.headers table */
|
||||
|
||||
r->headers_out.headers.elts = ngx_pcalloc(r->pool,
|
||||
20 * sizeof(ngx_table_elt_t));
|
||||
if (r->headers_out.headers.elts == NULL) {
|
||||
ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||
ngx_http_close_connection(c);
|
||||
return;
|
||||
}
|
||||
/* r->headers_out.headers.nelts = 0; */
|
||||
r->headers_out.headers.nalloc = 20;
|
||||
r->headers_out.headers.size = sizeof(ngx_table_elt_t);
|
||||
r->headers_out.headers.pool = r->pool;
|
||||
|
||||
|
||||
r->ctx = ngx_pcalloc(r->pool, sizeof(void *) * ngx_http_max_module);
|
||||
if (r->ctx == NULL) {
|
||||
@ -469,11 +477,26 @@ static void ngx_http_process_request_line(ngx_event_t *rev)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* init the r->headers_in.headers table */
|
||||
|
||||
r->headers_in.headers.elts = ngx_pcalloc(r->pool,
|
||||
20 * sizeof(ngx_table_elt_t));
|
||||
if (r->headers_in.headers.elts == NULL) {
|
||||
ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
|
||||
ngx_http_close_connection(c);
|
||||
return;
|
||||
}
|
||||
|
||||
/* r->headers_in.headers.elts = NULL; */
|
||||
/* r->headers_in.headers.nelts = 0; */
|
||||
r->headers_in.headers.size = sizeof(ngx_table_elt_t);
|
||||
r->headers_in.headers.nalloc = 20;
|
||||
r->headers_in.headers.pool = r->pool;
|
||||
|
||||
ctx = c->log->data;
|
||||
ctx->action = "reading client request headers";
|
||||
ctx->url = r->unparsed_uri.data;
|
||||
/* TODO: ngx_init_table */
|
||||
r->headers_in.headers = ngx_create_table(r->pool, 20);
|
||||
|
||||
if (cscf->large_client_header
|
||||
&& r->header_in->pos == r->header_in->last)
|
||||
@ -848,21 +871,6 @@ static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r)
|
||||
if (r->headers_in.content_length_n == NGX_ERROR) {
|
||||
return NGX_HTTP_PARSE_INVALID_CL_HEADER;
|
||||
}
|
||||
|
||||
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
|
||||
|
||||
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
|
||||
"http cl: " SIZE_T_FMT " max: " SIZE_T_FMT,
|
||||
r->headers_in.content_length_n,
|
||||
clcf->client_max_body_size);
|
||||
|
||||
if (clcf->client_max_body_size
|
||||
&& clcf->client_max_body_size
|
||||
< (size_t) r->headers_in.content_length_n)
|
||||
{
|
||||
return NGX_HTTP_PARSE_ENTITY_TOO_LARGE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (r->headers_in.connection) {
|
||||
@ -913,6 +921,12 @@ void ngx_http_finalize_request(ngx_http_request_t *r, int rc)
|
||||
ngx_del_timer(r->connection->write);
|
||||
}
|
||||
|
||||
if (rc == NGX_HTTP_CLIENT_CLOSED_REQUEST || r->closed) {
|
||||
ngx_http_close_request(r, 0);
|
||||
ngx_http_close_connection(r->connection);
|
||||
return;
|
||||
}
|
||||
|
||||
ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc));
|
||||
|
||||
return;
|
||||
@ -1098,8 +1112,6 @@ int ngx_http_discard_body(ngx_http_request_t *r)
|
||||
}
|
||||
|
||||
return ngx_http_read_discarded_body(r);
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -1158,7 +1170,15 @@ static int ngx_http_read_discarded_body(ngx_http_request_t *r)
|
||||
|
||||
n = ngx_recv(r->connection, r->discarded_buffer, size);
|
||||
if (n == NGX_ERROR) {
|
||||
return NGX_HTTP_BAD_REQUEST;
|
||||
|
||||
r->closed = 1;
|
||||
|
||||
/*
|
||||
* when a client request body is discarded then we already set
|
||||
* some HTTP response code for client and we can ignore the error
|
||||
*/
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
if (n == NGX_AGAIN) {
|
||||
@ -1606,19 +1626,9 @@ static void ngx_http_client_error(ngx_http_request_t *r,
|
||||
r->connection->log->handler = NULL;
|
||||
|
||||
if (ctx->url) {
|
||||
if (client_error == NGX_HTTP_PARSE_ENTITY_TOO_LARGE) {
|
||||
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
||||
client_header_errors[client_error - NGX_HTTP_CLIENT_ERROR],
|
||||
ctx->client, r->headers_in.content_length_n, ctx->url);
|
||||
|
||||
error = NGX_HTTP_REQUEST_ENTITY_TOO_LARGE;
|
||||
r->lingering_close = 1;
|
||||
|
||||
} else {
|
||||
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
||||
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
|
||||
client_header_errors[client_error - NGX_HTTP_CLIENT_ERROR],
|
||||
ctx->client, ctx->url);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (error == NGX_HTTP_REQUEST_URI_TOO_LARGE) {
|
||||
|
@ -30,7 +30,6 @@
|
||||
#define NGX_HTTP_PARSE_TOO_LONG_HEADER 15
|
||||
#define NGX_HTTP_PARSE_NO_HOST_HEADER 16
|
||||
#define NGX_HTTP_PARSE_INVALID_CL_HEADER 17
|
||||
#define NGX_HTTP_PARSE_ENTITY_TOO_LARGE 18
|
||||
|
||||
|
||||
#define NGX_HTTP_OK 200
|
||||
@ -87,7 +86,7 @@ typedef struct {
|
||||
|
||||
|
||||
typedef struct {
|
||||
ngx_table_t *headers; /* it must be first field */
|
||||
ngx_table_t headers; /* it must be first field */
|
||||
|
||||
ngx_table_elt_t *host;
|
||||
ngx_table_elt_t *connection;
|
||||
@ -137,7 +136,7 @@ typedef struct {
|
||||
|
||||
|
||||
typedef struct {
|
||||
ngx_table_t *headers; /* it must be first field */
|
||||
ngx_table_t headers; /* it must be first field */
|
||||
|
||||
int status;
|
||||
ngx_str_t status_line;
|
||||
@ -265,9 +264,7 @@ struct ngx_http_request_s {
|
||||
unsigned header_only:1;
|
||||
unsigned keepalive:1;
|
||||
unsigned lingering_close:1;
|
||||
#if 0
|
||||
unsigned closed:1;
|
||||
#endif
|
||||
|
||||
/* TODO: use the filter flags or the separate bits ???? */
|
||||
u_int filter;
|
||||
|
@ -12,7 +12,6 @@ static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r);
|
||||
ngx_int_t ngx_http_read_client_request_body(ngx_http_request_t *r,
|
||||
size_t request_buffer_size)
|
||||
{
|
||||
ngx_int_t rc;
|
||||
ssize_t size;
|
||||
ngx_hunk_t *h;
|
||||
ngx_chain_t *cl;
|
||||
@ -143,12 +142,17 @@ static ngx_int_t ngx_http_do_read_client_request_body(ngx_http_request_t *r)
|
||||
}
|
||||
|
||||
if (n == 0 || n == NGX_ERROR) {
|
||||
r->closed = 1;
|
||||
return NGX_HTTP_BAD_REQUEST;
|
||||
}
|
||||
|
||||
r->request_body_hunk->last += n;
|
||||
r->request_body_len -= n;
|
||||
|
||||
if (r->request_body_len == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (r->request_body_hunk->last < r->request_body_hunk->end) {
|
||||
break;
|
||||
}
|
||||
|
@ -185,8 +185,8 @@ int ngx_http_special_response_handler(ngx_http_request_t *r, int error)
|
||||
|
||||
rc = ngx_http_discard_body(r);
|
||||
|
||||
if (rc != NGX_OK) {
|
||||
return rc;
|
||||
if (rc == NGX_HTTP_INTERNAL_SERVER_ERROR) {
|
||||
error = NGX_HTTP_INTERNAL_SERVER_ERROR;
|
||||
}
|
||||
|
||||
r->headers_out.status = error;
|
||||
|
@ -96,7 +96,7 @@ extern LPFN_GETACCEPTEXSOCKADDRS getacceptexsockaddrs;
|
||||
extern LPFN_TRANSMITFILE transmitfile;
|
||||
|
||||
|
||||
static ngx_inline int ngx_tcp_push(ngx_socket_t s) {
|
||||
ngx_inline static int ngx_tcp_push(ngx_socket_t s) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@
|
||||
#include <ngx_auto_config.h>
|
||||
|
||||
|
||||
#define ngx_inlie __inline
|
||||
#define ngx_inline __inline
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
Loading…
Reference in New Issue
Block a user