19
19
20
20
#define _GNU_SOURCE
21
21
#include <string.h>
22
+ #include <stdio.h>
22
23
23
24
#include <fluent-bit/flb_info.h>
24
25
#include <fluent-bit/flb_kv.h>
@@ -285,27 +286,24 @@ static int http2_data_chunk_recv_callback(nghttp2_session *inner_session,
285
286
return -1 ;
286
287
}
287
288
288
- memcpy (stream -> response .body , data , len );
289
+ cfl_sds_set_len (stream -> response .body , 0 );
289
290
290
- cfl_sds_set_len (stream -> response .body , len );
291
-
292
- stream -> response .body_read_offset = len ;
291
+ stream -> response .body_read_offset = 0 ;
293
292
}
294
- else {
295
- resized_buffer = cfl_sds_cat (stream -> response .body ,
296
- (const char * ) data ,
297
- len );
298
293
299
- if (resized_buffer == NULL ) {
300
- stream -> status = HTTP_STREAM_STATUS_ERROR ;
294
+ resized_buffer = cfl_sds_cat (stream -> response .body ,
295
+ (const char * ) data ,
296
+ len );
301
297
302
- return -1 ;
303
- }
298
+ if ( resized_buffer == NULL ) {
299
+ stream -> status = HTTP_STREAM_STATUS_ERROR ;
304
300
305
- stream -> response .body = resized_buffer ;
306
- stream -> response .body_read_offset += len ;
301
+ return -1 ;
307
302
}
308
303
304
+ stream -> response .body = resized_buffer ;
305
+ stream -> response .body_read_offset += len ;
306
+
309
307
if (stream -> status == HTTP_STREAM_STATUS_RECEIVING_DATA ) {
310
308
if (stream -> response .content_length >=
311
309
stream -> response .body_read_offset ) {
@@ -387,7 +385,7 @@ static ssize_t http2_data_source_read_callback(nghttp2_session *session,
387
385
388
386
int flb_http2_client_session_init (struct flb_http2_client_session * session )
389
387
{
390
- nghttp2_settings_entry session_settings [1 ];
388
+ nghttp2_settings_entry session_settings [3 ];
391
389
nghttp2_session_callbacks * callbacks ;
392
390
int result ;
393
391
@@ -422,10 +420,17 @@ int flb_http2_client_session_init(struct flb_http2_client_session *session)
422
420
session_settings [0 ].settings_id = NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS ;
423
421
session_settings [0 ].value = 1 ;
424
422
423
+ session_settings [1 ].settings_id = NGHTTP2_SETTINGS_MAX_FRAME_SIZE ;
424
+ session_settings [1 ].value = cfl_sds_alloc (session -> parent -> parent -> temporary_buffer );
425
+
426
+ session_settings [2 ].settings_id = NGHTTP2_SETTINGS_ENABLE_PUSH ;
427
+ session_settings [2 ].value = 0 ;
428
+
429
+
425
430
result = nghttp2_submit_settings (session -> inner_session ,
426
431
NGHTTP2_FLAG_NONE ,
427
432
session_settings ,
428
- 1 );
433
+ 3 );
429
434
430
435
if (result != 0 ) {
431
436
return -3 ;
@@ -480,6 +485,7 @@ int flb_http2_request_begin(struct flb_http_request *request)
480
485
int flb_http2_request_commit (struct flb_http_request * request )
481
486
{
482
487
struct flb_http_client_session * parent_session ;
488
+ cfl_sds_t sds_result ;
483
489
struct flb_http2_client_session * session ;
484
490
struct flb_http_stream * stream ;
485
491
int result ;
@@ -517,10 +523,10 @@ int flb_http2_request_commit(struct flb_http_request *request)
517
523
}
518
524
519
525
if (parent_session -> connection -> tls_session != NULL ) {
520
- scheme_as_text = "HTTPS " ;
526
+ scheme_as_text = "https " ;
521
527
}
522
528
else {
523
- scheme_as_text = "HTTP " ;
529
+ scheme_as_text = "http " ;
524
530
}
525
531
526
532
switch (request -> method ) {
@@ -554,6 +560,22 @@ int flb_http2_request_commit(struct flb_http_request *request)
554
560
return -1 ;
555
561
}
556
562
563
+ if (request -> authority == NULL ) {
564
+ request -> authority = cfl_sds_create (request -> host );
565
+
566
+ if (request -> authority == NULL ) {
567
+ return -1 ;
568
+ }
569
+
570
+ sds_result = cfl_sds_printf (& request -> authority ,
571
+ ":%u" ,
572
+ request -> port );
573
+
574
+ if (sds_result == NULL ) {
575
+ return -1 ;
576
+ }
577
+ }
578
+
557
579
header_count = request -> headers -> total_count + 7 ;
558
580
559
581
headers = flb_calloc (header_count , sizeof (nghttp2_nv ));
@@ -580,8 +602,8 @@ int flb_http2_request_commit(struct flb_http_request *request)
580
602
581
603
headers [header_index ].name = (uint8_t * ) ":authority" ;
582
604
headers [header_index ].namelen = strlen (":authority" );
583
- headers [header_index ].value = (uint8_t * ) request -> host ;
584
- headers [header_index ].valuelen = strlen (request -> host );
605
+ headers [header_index ].value = (uint8_t * ) request -> authority ;
606
+ headers [header_index ].valuelen = strlen (request -> authority );
585
607
586
608
header_index ++ ;
587
609
0 commit comments