diff options
Diffstat (limited to 'src/http/ngx_http_upstream.c')
-rw-r--r-- | src/http/ngx_http_upstream.c | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index f59ff179e..c575347db 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -241,7 +241,9 @@ ngx_http_upstream_init(ngx_http_request_t *r) u = r->upstream; - u->request_bufs = r->request_body->bufs; + if (r->request_body) { + u->request_bufs = r->request_body->bufs; + } if (u->conf->method == NGX_CONF_UNSET_UINT) { u->method = r->method; @@ -250,7 +252,7 @@ ngx_http_upstream_init(ngx_http_request_t *r) u->method = u->conf->method; } - if (u->create_request(r) == NGX_ERROR) { + if (u->create_request(r) != NGX_OK) { ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); return; } @@ -615,9 +617,8 @@ ngx_http_upstream_send_request(ngx_http_request_t *r, ngx_http_upstream_t *u) && !u->request_sent && c->write->pending_eof) { - ngx_log_error(NGX_LOG_ERR, c->log, c->write->kq_errno, - "connect() failed"); - + (void) ngx_connection_error(c, c->write->kq_errno, + "kevent() reported that connect() failed"); ngx_http_upstream_next(r, u, NGX_HTTP_UPSTREAM_FT_ERROR); return; } @@ -716,12 +717,6 @@ ngx_http_upstream_send_request_handler(ngx_event_t *wev) return; } - if (r->connection->write->eof && (!u->cachable || !u->request_sent)) { - ngx_http_upstream_finalize_request(r, u, - NGX_HTTP_INTERNAL_SERVER_ERROR); - return; - } - ngx_http_upstream_send_request(r, u); } @@ -1788,6 +1783,7 @@ static u_char * ngx_http_upstream_log_error(ngx_http_request_t *r, u_char *buf, size_t len) { u_char *p; + ngx_str_t line; uintptr_t escape; ngx_http_upstream_t *u; ngx_peer_connection_t *peer; @@ -1824,33 +1820,35 @@ ngx_http_upstream_log_error(ngx_http_request_t *r, u_char *buf, size_t len) buf += r->uri.len - u->conf->location->len + escape; len -= r->uri.len - u->conf->location->len + escape; - if (r->args.len) { - p = ngx_snprintf(buf, len, "?%V", &r->args); - len -= p - buf; - buf = p; + } else { + p = ngx_palloc(r->pool, + r->uri.len - u->conf->location->len + escape); + if (p == NULL) { + return buf; } - return ngx_http_log_error_info(r, buf, len); - } + ngx_escape_uri(p, r->uri.data + u->conf->location->len, + r->uri.len - u->conf->location->len, NGX_ESCAPE_URI); - p = ngx_palloc(r->pool, r->uri.len - u->conf->location->len + escape); - if (p == NULL) { - return buf; + line.len = len; + line.data = p; + + return ngx_snprintf(buf, len, "%V", &line); } - ngx_escape_uri(p, r->uri.data + u->conf->location->len, - r->uri.len - u->conf->location->len, NGX_ESCAPE_URI); + } else { + line.len = r->uri.len - u->conf->location->len; + if (line.len > len) { + line.len = len; + } - p = ngx_cpymem(buf, p, r->uri.len - u->conf->location->len + escape); + line.data = r->uri.data + u->conf->location->len; + p = ngx_snprintf(buf, len, "%V", &line); - } else { - p = ngx_cpymem(buf, r->uri.data + u->conf->location->len, - r->uri.len - u->conf->location->len); + len -= p - buf; + buf = p; } - len -= p - buf; - buf = p; - if (r->args.len) { p = ngx_snprintf(buf, len, "?%V", &r->args); len -= p - buf; |