@@ -257,7 +257,7 @@ typedef struct ngx_http_upload_ctx_s {
257
257
unsigned int raw_input :1 ;
258
258
} ngx_http_upload_ctx_t ;
259
259
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 );
261
261
262
262
static ngx_int_t ngx_http_upload_handler (ngx_http_request_t * r );
263
263
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)
840
840
return rc ;
841
841
}
842
842
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
+ }
847
847
848
848
if (upload_start (u , ulcf ) != NGX_OK )
849
849
return NGX_HTTP_INTERNAL_SERVER_ERROR ;
@@ -4031,3 +4031,43 @@ ngx_upload_cleanup_handler(void *data)
4031
4031
}
4032
4032
} /* }}} */
4033
4033
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