@@ -90,37 +90,38 @@ static int handle_http1_static_resource(
90
90
int len ;
91
91
int ret ;
92
92
93
- if (static_detail -> common .bitmask_of_supported_http_methods & BIT (HTTP_GET )) {
94
- data = static_detail -> static_data ;
95
- len = static_detail -> static_data_len ;
96
-
97
- if (static_detail -> common .content_encoding != NULL &&
98
- static_detail -> common .content_encoding [0 ] != '\0' ) {
99
- snprintk (http_response , sizeof (http_response ),
100
- RESPONSE_TEMPLATE "Content-Encoding: %s\r\n\r\n" ,
101
- "Content-Type: " ,
102
- static_detail -> common .content_type == NULL ?
103
- "text/html" : static_detail -> common .content_type ,
104
- len , static_detail -> common .content_encoding );
105
- } else {
106
- snprintk (http_response , sizeof (http_response ),
107
- RESPONSE_TEMPLATE "\r\n" ,
108
- "Content-Type: " ,
109
- static_detail -> common .content_type == NULL ?
110
- "text/html" : static_detail -> common .content_type ,
111
- len );
112
- }
93
+ if (client -> method != HTTP_GET ) {
94
+ return send_http1_405 (client );
95
+ }
113
96
114
- ret = http_server_sendall (client , http_response ,
115
- strlen (http_response ));
116
- if (ret < 0 ) {
117
- return ret ;
118
- }
97
+ data = static_detail -> static_data ;
98
+ len = static_detail -> static_data_len ;
119
99
120
- ret = http_server_sendall (client , data , len );
121
- if (ret < 0 ) {
122
- return ret ;
123
- }
100
+ if (static_detail -> common .content_encoding != NULL &&
101
+ static_detail -> common .content_encoding [0 ] != '\0' ) {
102
+ snprintk (http_response , sizeof (http_response ),
103
+ RESPONSE_TEMPLATE "Content-Encoding: %s\r\n\r\n" ,
104
+ "Content-Type: " ,
105
+ static_detail -> common .content_type == NULL ?
106
+ "text/html" : static_detail -> common .content_type ,
107
+ len , static_detail -> common .content_encoding );
108
+ } else {
109
+ snprintk (http_response , sizeof (http_response ),
110
+ RESPONSE_TEMPLATE "\r\n" ,
111
+ "Content-Type: " ,
112
+ static_detail -> common .content_type == NULL ?
113
+ "text/html" : static_detail -> common .content_type ,
114
+ len );
115
+ }
116
+
117
+ ret = http_server_sendall (client , http_response , strlen (http_response ));
118
+ if (ret < 0 ) {
119
+ return ret ;
120
+ }
121
+
122
+ ret = http_server_sendall (client , data , len );
123
+ if (ret < 0 ) {
124
+ return ret ;
124
125
}
125
126
126
127
return 0 ;
@@ -441,7 +442,7 @@ int handle_http1_static_fs_resource(struct http_resource_detail_static_fs *stati
441
442
sizeof ("Content-Length: 01234567890123456789\r\n" ) +
442
443
sizeof (CONTENT_ENCODING_GZIP )];
443
444
444
- if (!( static_fs_detail -> common . bitmask_of_supported_http_methods & BIT ( HTTP_GET )) ) {
445
+ if (client -> method != HTTP_GET ) {
445
446
return send_http1_405 (client );
446
447
}
447
448
@@ -521,7 +522,7 @@ static int handle_http1_dynamic_resource(
521
522
user_method = dynamic_detail -> common .bitmask_of_supported_http_methods ;
522
523
523
524
if (!(BIT (client -> method ) & user_method )) {
524
- return - ENOPROTOOPT ;
525
+ return send_http1_405 ( client ) ;
525
526
}
526
527
527
528
if (dynamic_detail -> holder != NULL && dynamic_detail -> holder != client ) {
0 commit comments