Latest update - 7220
This commit is contained in:
@@ -55,8 +55,6 @@ static ngx_int_t ngx_http_upstream_intercept_errors(ngx_http_request_t *r,
|
||||
static ngx_int_t ngx_http_upstream_test_connect(ngx_connection_t *c);
|
||||
static ngx_int_t ngx_http_upstream_process_headers(ngx_http_request_t *r,
|
||||
ngx_http_upstream_t *u);
|
||||
static void ngx_http_upstream_process_body_in_memory(ngx_http_request_t *r,
|
||||
ngx_http_upstream_t *u);
|
||||
static void ngx_http_upstream_send_response(ngx_http_request_t *r,
|
||||
ngx_http_upstream_t *u);
|
||||
static void ngx_http_upstream_upgrade(ngx_http_request_t *r,
|
||||
@@ -2346,45 +2344,7 @@ ngx_http_upstream_process_header(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!r->subrequest_in_memory) {
|
||||
ngx_http_upstream_send_response(r, u);
|
||||
return;
|
||||
}
|
||||
|
||||
/* subrequest content in memory */
|
||||
|
||||
if (u->input_filter == NULL) {
|
||||
u->input_filter_init = ngx_http_upstream_non_buffered_filter_init;
|
||||
u->input_filter = ngx_http_upstream_non_buffered_filter;
|
||||
u->input_filter_ctx = r;
|
||||
}
|
||||
|
||||
if (u->input_filter_init(u->input_filter_ctx) == NGX_ERROR) {
|
||||
ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
n = u->buffer.last - u->buffer.pos;
|
||||
|
||||
if (n) {
|
||||
u->buffer.last = u->buffer.pos;
|
||||
|
||||
u->state->response_length += n;
|
||||
|
||||
if (u->input_filter(u->input_filter_ctx, n) == NGX_ERROR) {
|
||||
ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (u->length == 0) {
|
||||
ngx_http_upstream_finalize_request(r, u, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
u->read_event_handler = ngx_http_upstream_process_body_in_memory;
|
||||
|
||||
ngx_http_upstream_process_body_in_memory(r, u);
|
||||
ngx_http_upstream_send_response(r, u);
|
||||
}
|
||||
|
||||
|
||||
@@ -2786,84 +2746,6 @@ ngx_http_upstream_process_headers(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ngx_http_upstream_process_body_in_memory(ngx_http_request_t *r,
|
||||
ngx_http_upstream_t *u)
|
||||
{
|
||||
size_t size;
|
||||
ssize_t n;
|
||||
ngx_buf_t *b;
|
||||
ngx_event_t *rev;
|
||||
ngx_connection_t *c;
|
||||
|
||||
c = u->peer.connection;
|
||||
rev = c->read;
|
||||
|
||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
||||
"http upstream process body in memory");
|
||||
|
||||
if (rev->timedout) {
|
||||
ngx_connection_error(c, NGX_ETIMEDOUT, "upstream timed out");
|
||||
ngx_http_upstream_finalize_request(r, u, NGX_HTTP_GATEWAY_TIME_OUT);
|
||||
return;
|
||||
}
|
||||
|
||||
b = &u->buffer;
|
||||
|
||||
for ( ;; ) {
|
||||
|
||||
size = b->end - b->last;
|
||||
|
||||
if (size == 0) {
|
||||
ngx_log_error(NGX_LOG_ALERT, c->log, 0,
|
||||
"upstream buffer is too small to read response");
|
||||
ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
n = c->recv(c, b->last, size);
|
||||
|
||||
if (n == NGX_AGAIN) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (n == 0 || n == NGX_ERROR) {
|
||||
ngx_http_upstream_finalize_request(r, u, n);
|
||||
return;
|
||||
}
|
||||
|
||||
u->state->bytes_received += n;
|
||||
u->state->response_length += n;
|
||||
|
||||
if (u->input_filter(u->input_filter_ctx, n) == NGX_ERROR) {
|
||||
ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!rev->ready) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (u->length == 0) {
|
||||
ngx_http_upstream_finalize_request(r, u, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ngx_handle_read_event(rev, 0) != NGX_OK) {
|
||||
ngx_http_upstream_finalize_request(r, u, NGX_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (rev->active) {
|
||||
ngx_add_timer(rev, u->conf->read_timeout);
|
||||
|
||||
} else if (rev->timer_set) {
|
||||
ngx_del_timer(rev);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ngx_http_upstream_send_response(ngx_http_request_t *r, ngx_http_upstream_t *u)
|
||||
{
|
||||
@@ -4370,12 +4252,6 @@ ngx_http_upstream_finalize_request(ngx_http_request_t *r,
|
||||
|
||||
#endif
|
||||
|
||||
if (r->subrequest_in_memory
|
||||
&& u->headers_in.status_n >= NGX_HTTP_SPECIAL_RESPONSE)
|
||||
{
|
||||
u->buffer.last = u->buffer.pos;
|
||||
}
|
||||
|
||||
r->read_event_handler = ngx_http_block_reading;
|
||||
|
||||
if (rc == NGX_DECLINED) {
|
||||
|
||||
Reference in New Issue
Block a user