@@ -76,8 +76,10 @@ static struct aws_s3express_session *s_aws_s3express_session_new(
7676 session -> impl = provider -> impl ;
7777 session -> hash_key = aws_string_new_from_string (provider -> allocator , hash_key );
7878 session -> host = aws_string_new_from_string (provider -> allocator , host );
79- aws_http_headers_acquire (headers );
80- session -> headers = headers ;
79+ if (headers != NULL ) {
80+ aws_http_headers_acquire (headers );
81+ session -> headers = headers ;
82+ }
8183 if (region ) {
8284 session -> region = aws_string_new_from_string (provider -> allocator , region );
8385 }
@@ -414,17 +416,18 @@ static struct aws_http_message *s_create_session_request_new(
414416 if (aws_http_message_add_header (request , user_agent_header )) {
415417 goto error ;
416418 }
417-
418- for (size_t header_index = 0 ; header_index < g_s3_create_session_allowed_headers_count ; ++ header_index ) {
419- struct aws_byte_cursor header_name = g_s3_create_session_allowed_headers [header_index ];
420- struct aws_byte_cursor header_value ;
421- if (aws_http_headers_get (headers , header_name , & header_value ) == AWS_OP_SUCCESS && header_value .len > 0 ) {
422- struct aws_http_header header = {
423- .name = header_name ,
424- .value = header_value ,
425- };
426- if (aws_http_message_add_header (request , header )) {
427- goto error ;
419+ if (headers != NULL ) {
420+ for (size_t header_index = 0 ; header_index < g_s3_create_session_allowed_headers_count ; ++ header_index ) {
421+ struct aws_byte_cursor header_name = g_s3_create_session_allowed_headers [header_index ];
422+ struct aws_byte_cursor header_value ;
423+ if (aws_http_headers_get (headers , header_name , & header_value ) == AWS_OP_SUCCESS && header_value .len > 0 ) {
424+ struct aws_http_header header = {
425+ .name = header_name ,
426+ .value = header_value ,
427+ };
428+ if (aws_http_message_add_header (request , header )) {
429+ goto error ;
430+ }
428431 }
429432 }
430433 }
@@ -483,16 +486,18 @@ struct aws_string *aws_encode_s3express_hash_key_new(
483486 aws_byte_buf_write_from_whole_cursor (& combined_hash_buf , secret_access_key );
484487
485488 /* Write the allowed headers into hash */
486- struct aws_byte_cursor collon = aws_byte_cursor_from_c_str (":" );
487- struct aws_byte_cursor comma = aws_byte_cursor_from_c_str ("," );
488- for (size_t header_index = 0 ; header_index < g_s3_create_session_allowed_headers_count ; ++ header_index ) {
489- struct aws_byte_cursor header_name = g_s3_create_session_allowed_headers [header_index ];
490- struct aws_byte_cursor header_value ;
491- if (aws_http_headers_get (headers , header_name , & header_value ) == AWS_OP_SUCCESS && header_value .len > 0 ) {
492- aws_byte_buf_write_from_whole_cursor (& combined_hash_buf , comma );
493- aws_byte_buf_write_from_whole_cursor (& combined_hash_buf , header_name );
494- aws_byte_buf_write_from_whole_cursor (& combined_hash_buf , collon );
495- aws_byte_buf_write_from_whole_cursor (& combined_hash_buf , header_value );
489+ if (headers != NULL ) {
490+ struct aws_byte_cursor collon = aws_byte_cursor_from_c_str (":" );
491+ struct aws_byte_cursor comma = aws_byte_cursor_from_c_str ("," );
492+ for (size_t header_index = 0 ; header_index < g_s3_create_session_allowed_headers_count ; ++ header_index ) {
493+ struct aws_byte_cursor header_name = g_s3_create_session_allowed_headers [header_index ];
494+ struct aws_byte_cursor header_value ;
495+ if (aws_http_headers_get (headers , header_name , & header_value ) == AWS_OP_SUCCESS && header_value .len > 0 ) {
496+ aws_byte_buf_write_from_whole_cursor (& combined_hash_buf , comma );
497+ aws_byte_buf_write_from_whole_cursor (& combined_hash_buf , header_name );
498+ aws_byte_buf_write_from_whole_cursor (& combined_hash_buf , collon );
499+ aws_byte_buf_write_from_whole_cursor (& combined_hash_buf , header_value );
500+ }
496501 }
497502 }
498503
@@ -539,8 +544,10 @@ static struct aws_s3express_session_creator *s_session_creator_new(
539544 session_creator -> provider = provider ;
540545 session_creator -> host = aws_string_new_from_cursor (session_creator -> allocator , & s3express_properties -> host );
541546 session_creator -> region = aws_string_new_from_cursor (session_creator -> allocator , & s3express_properties -> region );
542- aws_http_headers_acquire (s3express_properties -> headers );
543- session_creator -> headers = s3express_properties -> headers ;
547+ if (s3express_properties -> headers != NULL ) {
548+ aws_http_headers_acquire (s3express_properties -> headers );
549+ session_creator -> headers = s3express_properties -> headers ;
550+ }
544551
545552 struct aws_signing_config_aws s3express_signing_config = {
546553 .credentials = original_credentials ,
0 commit comments