Skip to content

Commit fb66c11

Browse files
author
Valery Kholodkov
committed
Last commit was broken, fixed it
1 parent 8d0991c commit fb66c11

File tree

1 file changed

+45
-5
lines changed

1 file changed

+45
-5
lines changed

ngx_http_upload_module.c

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ typedef struct ngx_http_upload_ctx_s {
257257
unsigned int raw_input:1;
258258
} ngx_http_upload_ctx_t;
259259

260-
ngx_int_t ngx_http_test_expect(ngx_http_request_t *r);
260+
static ngx_int_t ngx_http_upload_test_expect(ngx_http_request_t *r);
261261

262262
static ngx_int_t ngx_http_upload_handler(ngx_http_request_t *r);
263263
static ngx_int_t ngx_http_upload_options_handler(ngx_http_request_t *r);
@@ -840,10 +840,10 @@ ngx_http_upload_handler(ngx_http_request_t *r)
840840
return rc;
841841
}
842842

843-
if (ngx_http_test_expect(r) != NGX_OK) {
844-
upload_shutdown_ctx(u);
845-
return NGX_HTTP_INTERNAL_SERVER_ERROR;
846-
}
843+
if (ngx_http_upload_test_expect(r) != NGX_OK) {
844+
upload_shutdown_ctx(u);
845+
return NGX_HTTP_INTERNAL_SERVER_ERROR;
846+
}
847847

848848
if(upload_start(u, ulcf) != NGX_OK)
849849
return NGX_HTTP_INTERNAL_SERVER_ERROR;
@@ -4031,3 +4031,43 @@ ngx_upload_cleanup_handler(void *data)
40314031
}
40324032
} /* }}} */
40334033

4034+
static ngx_int_t /* {{{ */
4035+
ngx_http_upload_test_expect(ngx_http_request_t *r)
4036+
{
4037+
ngx_int_t n;
4038+
ngx_str_t *expect;
4039+
4040+
if (r->expect_tested
4041+
|| r->headers_in.expect == NULL
4042+
|| r->http_version < NGX_HTTP_VERSION_11)
4043+
{
4044+
return NGX_OK;
4045+
}
4046+
4047+
r->expect_tested = 1;
4048+
4049+
expect = &r->headers_in.expect->value;
4050+
4051+
if (expect->len != sizeof("100-continue") - 1
4052+
|| ngx_strncasecmp(expect->data, (u_char *) "100-continue",
4053+
sizeof("100-continue") - 1)
4054+
!= 0)
4055+
{
4056+
return NGX_OK;
4057+
}
4058+
4059+
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
4060+
"send 100 Continue");
4061+
4062+
n = r->connection->send(r->connection,
4063+
(u_char *) "HTTP/1.1 100 Continue" CRLF CRLF,
4064+
sizeof("HTTP/1.1 100 Continue" CRLF CRLF) - 1);
4065+
4066+
if (n == sizeof("HTTP/1.1 100 Continue" CRLF CRLF) - 1) {
4067+
return NGX_OK;
4068+
}
4069+
4070+
/* we assume that such small packet should be send successfully */
4071+
4072+
return NGX_ERROR;
4073+
} /* }}} */

0 commit comments

Comments
 (0)