@@ -117,7 +117,8 @@ static int handle_http1_static_resource(
117
117
"Transfer-Encoding: chunked\r\n"
118
118
119
119
static int http1_send_headers (struct http_client_ctx * client , enum http_status status ,
120
- const struct http_header * headers , size_t header_count )
120
+ const struct http_header * headers , size_t header_count ,
121
+ struct http_resource_detail_dynamic * dynamic_detail )
121
122
{
122
123
int ret ;
123
124
bool content_type_sent = false;
@@ -183,8 +184,8 @@ static int http1_send_headers(struct http_client_ctx *client, enum http_status s
183
184
if (!content_type_sent ) {
184
185
const char * content_type = NULL ;
185
186
186
- if (client -> current_detail != NULL ) {
187
- content_type = client -> current_detail -> content_type ;
187
+ if (dynamic_detail != NULL ) {
188
+ content_type = dynamic_detail -> common . content_type ;
188
189
}
189
190
190
191
snprintk (http_response , sizeof (http_response ), "Content-Type: %s\r\n" ,
@@ -208,7 +209,8 @@ static int http1_send_headers(struct http_client_ctx *client, enum http_status s
208
209
return ret ;
209
210
}
210
211
211
- static int http1_dynamic_response (struct http_client_ctx * client , struct http_response_ctx * rsp )
212
+ static int http1_dynamic_response (struct http_client_ctx * client , struct http_response_ctx * rsp ,
213
+ struct http_resource_detail_dynamic * dynamic_detail )
212
214
{
213
215
int ret ;
214
216
char tmp [TEMP_BUF_LEN ];
@@ -224,7 +226,8 @@ static int http1_dynamic_response(struct http_client_ctx *client, struct http_re
224
226
rsp -> status = 200 ;
225
227
}
226
228
227
- ret = http1_send_headers (client , rsp -> status , rsp -> headers , rsp -> header_count );
229
+ ret = http1_send_headers (client , rsp -> status , rsp -> headers , rsp -> header_count ,
230
+ dynamic_detail );
228
231
if (ret < 0 ) {
229
232
return ret ;
230
233
}
@@ -285,7 +288,7 @@ static int dynamic_get_req(struct http_resource_detail_dynamic *dynamic_detail,
285
288
return ret ;
286
289
}
287
290
288
- ret = http1_dynamic_response (client , & response_ctx );
291
+ ret = http1_dynamic_response (client , & response_ctx , dynamic_detail );
289
292
if (ret < 0 ) {
290
293
return ret ;
291
294
}
@@ -324,7 +327,7 @@ static int dynamic_post_req(struct http_resource_detail_dynamic *dynamic_detail,
324
327
}
325
328
326
329
copy_len = MIN (remaining , dynamic_detail -> data_buffer_len );
327
- while (copy_len > 0 ) {
330
+ while (1 ) {
328
331
enum http_data_status status ;
329
332
330
333
ptr = & start [offset ];
@@ -347,14 +350,14 @@ static int dynamic_post_req(struct http_resource_detail_dynamic *dynamic_detail,
347
350
}
348
351
349
352
if (http_response_is_provided (& response_ctx )) {
350
- ret = http1_dynamic_response (client , & response_ctx );
353
+ ret = http1_dynamic_response (client , & response_ctx , dynamic_detail );
351
354
if (ret < 0 ) {
352
355
return ret ;
353
356
}
357
+ }
354
358
355
- if (http_response_is_final (& response_ctx , status )) {
356
- break ;
357
- }
359
+ if (http_response_is_final (& response_ctx , status )) {
360
+ break ;
358
361
}
359
362
360
363
offset += copy_len ;
@@ -366,7 +369,7 @@ static int dynamic_post_req(struct http_resource_detail_dynamic *dynamic_detail,
366
369
if (!client -> http1_headers_sent ) {
367
370
memset (& response_ctx , 0 , sizeof (response_ctx ));
368
371
response_ctx .final_chunk = true;
369
- ret = http1_dynamic_response (client , & response_ctx );
372
+ ret = http1_dynamic_response (client , & response_ctx , dynamic_detail );
370
373
if (ret < 0 ) {
371
374
return ret ;
372
375
}
0 commit comments