mirror of
https://github.com/YGGverse/aquatic.git
synced 2026-03-31 17:55:36 +00:00
aquatic_http_protocol: urlencode/urldecode Request.key
About 11% performance regression for Request::from_bytes
This commit is contained in:
parent
0a0b57a9e8
commit
74a538963f
7 changed files with 1014 additions and 1007 deletions
|
|
@ -52,7 +52,7 @@ impl AnnounceRequest {
|
|||
|
||||
if let Some(ref key) = self.key {
|
||||
output.write_all(b"&key=")?;
|
||||
output.write_all(key.as_str().as_bytes())?;
|
||||
output.write_all(::urlencoding::encode(key.as_str()).as_bytes())?;
|
||||
}
|
||||
|
||||
output.write_all(b" HTTP/1.1\r\nConnection: keep-alive\r\n\r\n")?;
|
||||
|
|
@ -220,7 +220,7 @@ impl Request {
|
|||
if value.len() > 100 {
|
||||
return Err(anyhow::anyhow!("'key' is too long"))
|
||||
}
|
||||
opt_key = Some(value.into());
|
||||
opt_key = Some(::urlencoding::decode(value)?.into());
|
||||
},
|
||||
k => {
|
||||
::log::info!("ignored unrecognized key: {}", k)
|
||||
|
|
@ -360,8 +360,7 @@ mod tests {
|
|||
fn quickcheck_serde_identity_request(){
|
||||
fn prop(request: Request) -> TestResult {
|
||||
if let Request::Announce(AnnounceRequest { key: Some(ref key), ..}) = request {
|
||||
if !key.is_ascii(){
|
||||
// Only ascii allowed in headers
|
||||
if key.len() > 30 {
|
||||
return TestResult::discard();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue