@@ -1825,6 +1825,157 @@ static int s_test_s3_put_object_less_than_part_size(struct aws_allocator *alloca
1825
1825
return 0 ;
1826
1826
}
1827
1827
1828
+ AWS_TEST_CASE (
1829
+ test_s3_put_object_less_than_part_size_with_content_encoding ,
1830
+ s_test_s3_put_object_less_than_part_size_with_content_encoding )
1831
+ static int s_test_s3_put_object_less_than_part_size_with_content_encoding (struct aws_allocator * allocator , void * ctx ) {
1832
+ (void )ctx ;
1833
+
1834
+ struct aws_s3_tester tester ;
1835
+ ASSERT_SUCCESS (aws_s3_tester_init (allocator , & tester ));
1836
+
1837
+ struct aws_s3_client_config client_config = {
1838
+ .part_size = 20 * 1024 * 1024 ,
1839
+ };
1840
+
1841
+ ASSERT_SUCCESS (aws_s3_tester_bind_client (
1842
+ & tester , & client_config , AWS_S3_TESTER_BIND_CLIENT_REGION | AWS_S3_TESTER_BIND_CLIENT_SIGNING ));
1843
+
1844
+ struct aws_s3_client * client = aws_s3_client_new (allocator , & client_config );
1845
+
1846
+ ASSERT_TRUE (client != NULL );
1847
+
1848
+ struct aws_byte_cursor content_encoding_cursor = aws_byte_cursor_from_c_str ("gzip" );
1849
+ uint32_t object_size_mb = 1 ;
1850
+ char object_path_sprintf_buffer [128 ] = "" ;
1851
+ snprintf (
1852
+ object_path_sprintf_buffer ,
1853
+ sizeof (object_path_sprintf_buffer ),
1854
+ "" PRInSTR "-content-encoding-%uMB.txt" ,
1855
+ AWS_BYTE_CURSOR_PRI (g_put_object_prefix ),
1856
+ object_size_mb );
1857
+ struct aws_byte_cursor object_path_cursor = aws_byte_cursor_from_c_str (object_path_sprintf_buffer );
1858
+
1859
+ /*** put file with encoding ***/
1860
+ struct aws_s3_tester_meta_request_options put_options = {
1861
+ .allocator = allocator ,
1862
+ .meta_request_type = AWS_S3_META_REQUEST_TYPE_PUT_OBJECT ,
1863
+ .client = client ,
1864
+ .checksum_algorithm = AWS_SCA_SHA256 ,
1865
+ .put_options =
1866
+ {
1867
+ .object_size_mb = object_size_mb ,
1868
+ .object_path_override = object_path_cursor ,
1869
+ .content_encoding = content_encoding_cursor ,
1870
+ },
1871
+ };
1872
+
1873
+ ASSERT_SUCCESS (aws_s3_tester_send_meta_request_with_options (& tester , & put_options , NULL ));
1874
+
1875
+ /*** get file and validate encoding ***/
1876
+ struct aws_s3_tester_meta_request_options get_options = {
1877
+ .allocator = allocator ,
1878
+ .meta_request_type = AWS_S3_META_REQUEST_TYPE_GET_OBJECT ,
1879
+ .validate_type = AWS_S3_TESTER_VALIDATE_TYPE_EXPECT_SUCCESS ,
1880
+ .client = client ,
1881
+ .get_options =
1882
+ {
1883
+ .object_path = object_path_cursor ,
1884
+ },
1885
+ };
1886
+
1887
+ struct aws_s3_meta_request_test_results get_object_result ;
1888
+ aws_s3_meta_request_test_results_init (& get_object_result , allocator );
1889
+
1890
+ ASSERT_SUCCESS (aws_s3_tester_send_meta_request_with_options (& tester , & get_options , & get_object_result ));
1891
+ struct aws_byte_cursor content_encoding_header_cursor ;
1892
+ ASSERT_SUCCESS (aws_http_headers_get (
1893
+ get_object_result .response_headers , g_content_encoding_header_name , & content_encoding_header_cursor ));
1894
+ ASSERT_TRUE (aws_byte_cursor_eq (& content_encoding_cursor , & content_encoding_header_cursor ));
1895
+ aws_s3_meta_request_test_results_clean_up (& get_object_result );
1896
+
1897
+ client = aws_s3_client_release (client );
1898
+
1899
+ aws_s3_tester_clean_up (& tester );
1900
+
1901
+ return 0 ;
1902
+ }
1903
+
1904
+ AWS_TEST_CASE (test_s3_put_object_mpu_with_content_encoding , s_test_s3_put_object_mpu_with_content_encoding )
1905
+ static int s_test_s3_put_object_mpu_with_content_encoding (struct aws_allocator * allocator , void * ctx ) {
1906
+ (void )ctx ;
1907
+
1908
+ struct aws_s3_tester tester ;
1909
+ ASSERT_SUCCESS (aws_s3_tester_init (allocator , & tester ));
1910
+
1911
+ struct aws_s3_client_config client_config = {
1912
+ .part_size = 5 * 1024 * 1024 ,
1913
+ };
1914
+
1915
+ ASSERT_SUCCESS (aws_s3_tester_bind_client (
1916
+ & tester , & client_config , AWS_S3_TESTER_BIND_CLIENT_REGION | AWS_S3_TESTER_BIND_CLIENT_SIGNING ));
1917
+
1918
+ struct aws_s3_client * client = aws_s3_client_new (allocator , & client_config );
1919
+
1920
+ ASSERT_TRUE (client != NULL );
1921
+
1922
+ struct aws_byte_cursor content_encoding_cursor = aws_byte_cursor_from_c_str ("gzip" );
1923
+ uint32_t object_size_mb = 10 ;
1924
+ char object_path_sprintf_buffer [128 ] = "" ;
1925
+ snprintf (
1926
+ object_path_sprintf_buffer ,
1927
+ sizeof (object_path_sprintf_buffer ),
1928
+ "" PRInSTR "-content-encoding-%uMB.txt" ,
1929
+ AWS_BYTE_CURSOR_PRI (g_put_object_prefix ),
1930
+ object_size_mb );
1931
+ struct aws_byte_cursor object_path_cursor = aws_byte_cursor_from_c_str (object_path_sprintf_buffer );
1932
+
1933
+ /*** put file with encoding ***/
1934
+ struct aws_s3_tester_meta_request_options put_options = {
1935
+ .allocator = allocator ,
1936
+ .meta_request_type = AWS_S3_META_REQUEST_TYPE_PUT_OBJECT ,
1937
+ .client = client ,
1938
+ .checksum_algorithm = AWS_SCA_SHA256 ,
1939
+ .put_options =
1940
+ {
1941
+ .object_size_mb = object_size_mb ,
1942
+ .object_path_override = object_path_cursor ,
1943
+ .content_encoding = content_encoding_cursor ,
1944
+ .ensure_multipart = true,
1945
+ },
1946
+ };
1947
+
1948
+ ASSERT_SUCCESS (aws_s3_tester_send_meta_request_with_options (& tester , & put_options , NULL ));
1949
+
1950
+ /*** get file and validate encoding ***/
1951
+ struct aws_s3_tester_meta_request_options get_options = {
1952
+ .allocator = allocator ,
1953
+ .meta_request_type = AWS_S3_META_REQUEST_TYPE_GET_OBJECT ,
1954
+ .validate_type = AWS_S3_TESTER_VALIDATE_TYPE_EXPECT_SUCCESS ,
1955
+ .client = client ,
1956
+ .get_options =
1957
+ {
1958
+ .object_path = object_path_cursor ,
1959
+ },
1960
+ };
1961
+
1962
+ struct aws_s3_meta_request_test_results get_object_result ;
1963
+ aws_s3_meta_request_test_results_init (& get_object_result , allocator );
1964
+
1965
+ ASSERT_SUCCESS (aws_s3_tester_send_meta_request_with_options (& tester , & get_options , & get_object_result ));
1966
+ struct aws_byte_cursor content_encoding_header_cursor ;
1967
+ ASSERT_SUCCESS (aws_http_headers_get (
1968
+ get_object_result .response_headers , g_content_encoding_header_name , & content_encoding_header_cursor ));
1969
+ ASSERT_TRUE (aws_byte_cursor_eq (& content_encoding_cursor , & content_encoding_header_cursor ));
1970
+ aws_s3_meta_request_test_results_clean_up (& get_object_result );
1971
+
1972
+ client = aws_s3_client_release (client );
1973
+
1974
+ aws_s3_tester_clean_up (& tester );
1975
+
1976
+ return 0 ;
1977
+ }
1978
+
1828
1979
AWS_TEST_CASE (test_s3_put_object_multipart_threshold , s_test_s3_put_object_multipart_threshold )
1829
1980
static int s_test_s3_put_object_multipart_threshold (struct aws_allocator * allocator , void * ctx ) {
1830
1981
(void )ctx ;
0 commit comments