diff --git a/Cargo.toml b/Cargo.toml index 362a862..bc60a99 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -45,7 +45,6 @@ futures = "0.1" tokio-io = "0.1.4" bytes = "0.4.7" http = "0.1.8" -byteorder = "1.0" log = "0.4.1" fnv = "1.0.5" slab = "0.4.0" diff --git a/src/frame/headers.rs b/src/frame/headers.rs index 6958f31..6f97875 100644 --- a/src/frame/headers.rs +++ b/src/frame/headers.rs @@ -5,7 +5,6 @@ use crate::hpack; use http::{uri, HeaderMap, Method, StatusCode, Uri}; use http::header::{self, HeaderName, HeaderValue}; -use byteorder::{BigEndian, ByteOrder}; use bytes::{Bytes, BytesMut}; use string::String; @@ -563,7 +562,9 @@ impl EncodingHeaderBlock { let payload_len = (dst.len() - payload_pos) as u64; // Write the frame length - BigEndian::write_uint(&mut dst[head_pos..head_pos + 3], payload_len, 3); + let payload_len_be = payload_len.to_be_bytes(); + assert!(payload_len_be[0..5].iter().all(|b| *b == 0)); + (&mut dst[head_pos..head_pos + 3]).copy_from_slice(&payload_len_be[5..]); if continuation.is_some() { // There will be continuation frames, so the `is_end_headers` flag diff --git a/src/frame/stream_id.rs b/src/frame/stream_id.rs index 039936f..10a14d3 100644 --- a/src/frame/stream_id.rs +++ b/src/frame/stream_id.rs @@ -1,4 +1,3 @@ -use byteorder::{BigEndian, ByteOrder}; use std::u32; /// A stream identifier, as described in [Section 5.1.1] of RFC 7540. @@ -29,7 +28,9 @@ impl StreamId { /// Parse the stream ID #[inline] pub fn parse(buf: &[u8]) -> (StreamId, bool) { - let unpacked = BigEndian::read_u32(buf); + let mut ubuf = [0; 4]; + ubuf.copy_from_slice(&buf[0..4]); + let unpacked = u32::from_be_bytes(ubuf); let flag = unpacked & STREAM_ID_MASK == STREAM_ID_MASK; // Now clear the most significant bit, as that is reserved and MUST be