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",
|
||||
"blocking",
|
||||
"bstr",
|
||||
"form_urlencoded",
|
||||
"futures",
|
||||
"futures-lite",
|
||||
"futures-rustls",
|
||||
|
|
|
@ -24,6 +24,7 @@ async-net = "2.0"
|
|||
async-tungstenite = "0.29"
|
||||
blocking = "1.6"
|
||||
bstr = "1.9"
|
||||
form_urlencoded = "1.2"
|
||||
futures = { version = "0.3", default-features = false, features = ["std"] }
|
||||
futures-lite = "2.6"
|
||||
futures-rustls = "0.26"
|
||||
|
|
|
@ -47,7 +47,7 @@ pub async fn send_request(mut request: Request, lua: Lua) -> LuaResult<Response>
|
|||
.uri()
|
||||
.to_string()
|
||||
.parse::<Url>()
|
||||
.expect("uri is valid");
|
||||
.into_lua_err()?;
|
||||
|
||||
// Some headers are required by most if not
|
||||
// all servers, make sure those are present...
|
||||
|
|
|
@ -110,15 +110,18 @@ impl Request {
|
|||
*/
|
||||
pub fn query(&self) -> HashMap<String, Vec<String>> {
|
||||
let uri = self.inner.uri();
|
||||
let url = uri.to_string().parse::<Url>().expect("uri is valid");
|
||||
|
||||
let mut result = HashMap::<String, Vec<String>>::new();
|
||||
for (key, value) in url.query_pairs() {
|
||||
result
|
||||
.entry(key.into_owned())
|
||||
.or_default()
|
||||
.push(value.into_owned());
|
||||
|
||||
if let Some(query) = uri.query() {
|
||||
for (key, value) in form_urlencoded::parse(query.as_bytes()) {
|
||||
result
|
||||
.entry(key.to_string())
|
||||
.or_default()
|
||||
.push(value.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue