mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Fix headers in net.serve being raw bytes instead of strings
This commit is contained in:
parent
fe55442dac
commit
03c773fd79
1 changed files with 15 additions and 6 deletions
|
@ -18,21 +18,30 @@ impl LuaRequest {
|
||||||
let path = self.head.uri.path().to_string();
|
let path = self.head.uri.path().to_string();
|
||||||
let body = lua.create_string(&self.body)?;
|
let body = lua.create_string(&self.body)?;
|
||||||
|
|
||||||
let query: HashMap<String, String> = self
|
let query: HashMap<LuaString, LuaString> = self
|
||||||
.head
|
.head
|
||||||
.uri
|
.uri
|
||||||
.query()
|
.query()
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
.split('&')
|
.split('&')
|
||||||
.filter_map(|q| q.split_once('='))
|
.filter_map(|q| q.split_once('='))
|
||||||
.map(|(k, v)| (k.to_string(), v.to_string()))
|
.map(|(k, v)| {
|
||||||
.collect();
|
let k = lua.create_string(k)?;
|
||||||
let headers: HashMap<String, Vec<u8>> = self
|
let v = lua.create_string(v)?;
|
||||||
|
Ok((k, v))
|
||||||
|
})
|
||||||
|
.collect::<LuaResult<_>>()?;
|
||||||
|
|
||||||
|
let headers: HashMap<LuaString, LuaString> = self
|
||||||
.head
|
.head
|
||||||
.headers
|
.headers
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(k, v)| (k.as_str().to_string(), v.as_bytes().to_vec()))
|
.map(|(k, v)| {
|
||||||
.collect();
|
let k = lua.create_string(k.as_str())?;
|
||||||
|
let v = lua.create_string(v.as_bytes())?;
|
||||||
|
Ok((k, v))
|
||||||
|
})
|
||||||
|
.collect::<LuaResult<_>>()?;
|
||||||
|
|
||||||
TableBuilder::new(lua)?
|
TableBuilder::new(lua)?
|
||||||
.with_value("method", method)?
|
.with_value("method", method)?
|
||||||
|
|
Loading…
Reference in a new issue