@@ -914,7 +914,7 @@ def method_req_1(self, request):
914914 request .send_response (307 )
915915 response = """<?xml version="1.0" encoding="UTF-8"?>
916916 <Error>
917- <Message>bla</ Message>
917+ <!-- no < Message> to test compatibility with OpenStack Swift on CloudFerro -- >
918918 <Code>TemporaryRedirect</Code>
919919 <Endpoint>localhost:%d</Endpoint>
920920 </Error>""" % request .server .port
@@ -984,6 +984,46 @@ def method_req_2(self, request):
984984 assert data == "bar"
985985
986986
987+ ###############################################################################
988+
989+
990+ @pytest .mark .parametrize ("with_error_message" , [True , False ])
991+ def test_vsis3_request_timeout (aws_test_config , webserver_port , with_error_message ):
992+ gdal .VSICurlClearCache ()
993+
994+ error_msg = "<Message>message</Message>" if with_error_message else ""
995+
996+ handler = webserver .SequentialHandler ()
997+ handler .add (
998+ "GET" ,
999+ "/test_vsis3_request_timeout/?delimiter=%2F&list-type=2" ,
1000+ 400 ,
1001+ {"Content-type" : "application/xml" },
1002+ f"""<?xml version="1.0" encoding="UTF-8"?>
1003+ <Error>{ error_msg }
1004+ <Code>RequestTimeout</Code>
1005+ </Error>""" ,
1006+ )
1007+ handler .add (
1008+ "GET" ,
1009+ "/test_vsis3_request_timeout/?delimiter=%2F&list-type=2" ,
1010+ 200 ,
1011+ {"Content-type" : "application/xml" },
1012+ """<?xml version="1.0" encoding="UTF-8"?>
1013+ <ListBucketResult>
1014+ <Prefix></Prefix>
1015+ <Contents>
1016+ <Key>test.bin</Key>
1017+ <LastModified>1970-01-01T00:00:01.000Z</LastModified>
1018+ <Size>123456</Size>
1019+ </Contents>
1020+ </ListBucketResult>""" ,
1021+ )
1022+ with webserver .install_http_handler (handler ):
1023+ with gdal .VSIFile ("/vsis3/test_vsis3_request_timeout/test.bin" , "rb" ):
1024+ pass
1025+
1026+
9871027###############################################################################
9881028# Test re-opening after changing configuration option (#2294)
9891029
@@ -1169,9 +1209,13 @@ def method(request):
11691209 )
11701210
11711211 with webserver .install_http_handler (handler ):
1172- f = open_for_read (
1173- "/vsis3/s3_fake_bucket2/a_dir with_space/resource3 with_space.bin"
1174- )
1212+ with gdaltest .error_raised (
1213+ gdal .CE_Warning ,
1214+ match = "Ignoring key 'a_dir with_space/../../not_ok' that has a path traversal pattern" ,
1215+ ):
1216+ f = open_for_read (
1217+ "/vsis3/s3_fake_bucket2/a_dir with_space/resource3 with_space.bin"
1218+ )
11751219 if f is None :
11761220 pytest .fail ()
11771221 gdal .VSIFCloseL (f )
0 commit comments