mirror of
https://github.com/lune-org/lune.git
synced 2025-05-04 10:43:57 +01:00
Url and uri are not the same
This commit is contained in:
parent
fb33d1812d
commit
66e3b58cd7
4 changed files with 12 additions and 7 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -1764,6 +1764,7 @@ dependencies = [
|
||||||
"async-tungstenite",
|
"async-tungstenite",
|
||||||
"blocking",
|
"blocking",
|
||||||
"bstr",
|
"bstr",
|
||||||
|
"form_urlencoded",
|
||||||
"futures",
|
"futures",
|
||||||
"futures-lite",
|
"futures-lite",
|
||||||
"futures-rustls",
|
"futures-rustls",
|
||||||
|
|
|
@ -24,6 +24,7 @@ async-net = "2.0"
|
||||||
async-tungstenite = "0.29"
|
async-tungstenite = "0.29"
|
||||||
blocking = "1.6"
|
blocking = "1.6"
|
||||||
bstr = "1.9"
|
bstr = "1.9"
|
||||||
|
form_urlencoded = "1.2"
|
||||||
futures = { version = "0.3", default-features = false, features = ["std"] }
|
futures = { version = "0.3", default-features = false, features = ["std"] }
|
||||||
futures-lite = "2.6"
|
futures-lite = "2.6"
|
||||||
futures-rustls = "0.26"
|
futures-rustls = "0.26"
|
||||||
|
|
|
@ -47,7 +47,7 @@ pub async fn send_request(mut request: Request, lua: Lua) -> LuaResult<Response>
|
||||||
.uri()
|
.uri()
|
||||||
.to_string()
|
.to_string()
|
||||||
.parse::<Url>()
|
.parse::<Url>()
|
||||||
.expect("uri is valid");
|
.into_lua_err()?;
|
||||||
|
|
||||||
// Some headers are required by most if not
|
// Some headers are required by most if not
|
||||||
// all servers, make sure those are present...
|
// all servers, make sure those are present...
|
||||||
|
|
|
@ -110,15 +110,18 @@ impl Request {
|
||||||
*/
|
*/
|
||||||
pub fn query(&self) -> HashMap<String, Vec<String>> {
|
pub fn query(&self) -> HashMap<String, Vec<String>> {
|
||||||
let uri = self.inner.uri();
|
let uri = self.inner.uri();
|
||||||
let url = uri.to_string().parse::<Url>().expect("uri is valid");
|
|
||||||
|
|
||||||
let mut result = HashMap::<String, Vec<String>>::new();
|
let mut result = HashMap::<String, Vec<String>>::new();
|
||||||
for (key, value) in url.query_pairs() {
|
|
||||||
result
|
if let Some(query) = uri.query() {
|
||||||
.entry(key.into_owned())
|
for (key, value) in form_urlencoded::parse(query.as_bytes()) {
|
||||||
.or_default()
|
result
|
||||||
.push(value.into_owned());
|
.entry(key.to_string())
|
||||||
|
.or_default()
|
||||||
|
.push(value.to_string());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue