about summary refs log tree commit diff
path: root/users/Profpatsch/read-http.rs
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2021-02-01T08·16+0100
committerProfpatsch <mail@profpatsch.de>2021-02-06T19·43+0000
commit14f9a22f4641ea214af1513bc1f9ef12b1350cbe (patch)
tree4ade52535f83d6fbd998667c714a2a93b981e98d /users/Profpatsch/read-http.rs
parente91d5e4e6102f2050138c80db2d6ec6c6c08ba26 (diff)
fix(users/Profpatsch/netencode): decode U::Text directly into str r/2183
Since `Text` is a scalar, it doesn’t make sense to delay the utf-8
verification to the consumer.

Change-Id: I36e4d228fbf35374d7c1addb4b24828cf6e927e5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2478
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
Diffstat (limited to 'users/Profpatsch/read-http.rs')
-rw-r--r--users/Profpatsch/read-http.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/users/Profpatsch/read-http.rs b/users/Profpatsch/read-http.rs
index de112f4c772d..42d4f37ff6c6 100644
--- a/users/Profpatsch/read-http.rs
+++ b/users/Profpatsch/read-http.rs
@@ -128,8 +128,8 @@ fn main() -> std::io::Result<()> {
 
 fn write_dict_req<'buf>(method: &'buf str, path: &'buf str, headers: &[(String, &str)]) -> std::io::Result<()> {
     let mut http = vec![
-        ("method", U::Text(method.as_bytes())),
-        ("path", U::Text(path.as_bytes())),
+        ("method", U::Text(method)),
+        ("path", U::Text(path)),
     ];
     write_dict(http, headers)
 }
@@ -137,7 +137,7 @@ fn write_dict_req<'buf>(method: &'buf str, path: &'buf str, headers: &[(String,
 fn write_dict_resp<'buf>(code: u16, reason: &'buf str, headers: &[(String, &str)]) -> std::io::Result<()> {
     let mut http = vec![
         ("status", U::N6(code as u64)),
-        ("status-text", U::Text(reason.as_bytes())),
+        ("status-text", U::Text(reason)),
     ];
     write_dict(http, headers)
 }
@@ -147,7 +147,7 @@ fn write_dict<'buf, 'a>(mut http: Vec<(&str, U<'a>)>, headers: &'a[(String, &str
     http.push(("headers", U::Record(
         headers.iter().map(
             |(name, value)|
-            (name.as_str(), U::Text(value.as_bytes()))
+            (name.as_str(), U::Text(value))
         ).collect::<Vec<_>>()
     )));