Skip to content

Commit 2da2c8e

Browse files
authored
fix(query): check storage request method with arg list-type (#16849)
* z * fix(query): check storage request method with arg list-type * z
1 parent 8409f90 commit 2da2c8e

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/common/storage/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ regex = { workspace = true }
3434
reqwest = { workspace = true }
3535
serde = { workspace = true }
3636
thiserror = { workspace = true }
37+
url = { workspace = true }
3738

3839
[dev-dependencies]
3940

src/common/storage/src/http_client.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use std::collections::HashMap;
1516
use std::future;
1617
use std::mem;
1718
use std::str::FromStr;
@@ -26,6 +27,7 @@ use opendal::raw::parse_content_length;
2627
use opendal::raw::HttpBody;
2728
use opendal::raw::HttpFetch;
2829
use opendal::Buffer;
30+
use url::Url;
2931

3032
pub struct StorageHttpClient {
3133
client: reqwest::Client,
@@ -46,13 +48,14 @@ impl HttpFetch for StorageHttpClient {
4648
let uri = req.uri().clone();
4749
let is_head = req.method() == http::Method::HEAD;
4850

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();
5053
let method = match req.method() {
5154
&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",
5659
}
5760
}
5861
m => m.as_str(),

0 commit comments

Comments
 (0)