File tree Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Expand file tree Collapse file tree 3 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ regex = { workspace = true }
34
34
reqwest = { workspace = true }
35
35
serde = { workspace = true }
36
36
thiserror = { workspace = true }
37
+ url = { workspace = true }
37
38
38
39
[dev-dependencies ]
39
40
Original file line number Diff line number Diff line change 12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
+ use std:: collections:: HashMap ;
15
16
use std:: future;
16
17
use std:: mem;
17
18
use std:: str:: FromStr ;
@@ -26,6 +27,7 @@ use opendal::raw::parse_content_length;
26
27
use opendal:: raw:: HttpBody ;
27
28
use opendal:: raw:: HttpFetch ;
28
29
use opendal:: Buffer ;
30
+ use url:: Url ;
29
31
30
32
pub struct StorageHttpClient {
31
33
client : reqwest:: Client ,
@@ -46,13 +48,14 @@ impl HttpFetch for StorageHttpClient {
46
48
let uri = req. uri ( ) . clone ( ) ;
47
49
let is_head = req. method ( ) == http:: Method :: HEAD ;
48
50
49
- let host = uri. host ( ) . unwrap_or_default ( ) ;
51
+ let url = Url :: parse ( uri. to_string ( ) . as_str ( ) ) . expect ( "input request url must be valid" ) ;
52
+ let host = url. host_str ( ) . unwrap_or_default ( ) ;
50
53
let method = match req. method ( ) {
51
54
& http:: Method :: GET => {
52
- if uri . path ( ) == "/" {
53
- "LIST"
54
- } else {
55
- "GET"
55
+ let query : HashMap < _ , _ > = url . query_pairs ( ) . collect ( ) ;
56
+ match query . get ( "list-type" ) {
57
+ Some ( _ ) => "LIST" ,
58
+ None => "GET" ,
56
59
}
57
60
}
58
61
m => m. as_str ( ) ,
You can’t perform that action at this time.
0 commit comments