Skip to content

Commit a2cd16d

Browse files
authored
Merge pull request #48 from sunfishcode/sunfishcode/constant-names
Use `http::header` constants.
2 parents 639f131 + bfd81e7 commit a2cd16d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/http/body.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
use crate::io::{AsyncInputStream, AsyncRead, Cursor, Empty};
44
use core::fmt;
5+
use http::header::{CONTENT_LENGTH, TRANSFER_ENCODING};
56
use wasi::http::types::IncomingBody as WasiIncomingBody;
67

78
pub use super::{
@@ -17,13 +18,13 @@ pub(crate) enum BodyKind {
1718

1819
impl BodyKind {
1920
pub(crate) fn from_headers(headers: &HeaderMap) -> Result<BodyKind, InvalidContentLength> {
20-
if let Some(value) = headers.get("content-length") {
21+
if let Some(value) = headers.get(CONTENT_LENGTH) {
2122
let content_length = std::str::from_utf8(value.as_ref())
2223
.unwrap()
2324
.parse::<u64>()
2425
.map_err(|_| InvalidContentLength)?;
2526
Ok(BodyKind::Fixed(content_length))
26-
} else if headers.contains_key("transfer-encoding") {
27+
} else if headers.contains_key(TRANSFER_ENCODING) {
2728
Ok(BodyKind::Chunked)
2829
} else {
2930
Ok(BodyKind::Chunked)

0 commit comments

Comments
 (0)