Fix warnings
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use super::{huffman, header as h2_header, Header};
|
||||
use super::{huffman, Header};
|
||||
use frame;
|
||||
use util::byte_str::FromUtf8Error;
|
||||
|
||||
use http::{method, header, status, StatusCode, Method};
|
||||
use http::{method, header, status};
|
||||
use bytes::{Buf, Bytes, BytesMut};
|
||||
|
||||
use std::cmp;
|
||||
@@ -409,10 +409,6 @@ impl Table {
|
||||
}
|
||||
}
|
||||
|
||||
fn max_size(&self) -> usize {
|
||||
self.max_size
|
||||
}
|
||||
|
||||
fn size(&self) -> usize {
|
||||
self.size
|
||||
}
|
||||
@@ -492,33 +488,36 @@ impl Table {
|
||||
// ===== impl DecoderError =====
|
||||
|
||||
impl From<FromUtf8Error> for DecoderError {
|
||||
fn from(src: FromUtf8Error) -> DecoderError {
|
||||
fn from(_: FromUtf8Error) -> DecoderError {
|
||||
// TODO: Better error?
|
||||
DecoderError::InvalidUtf8
|
||||
}
|
||||
}
|
||||
|
||||
impl From<header::InvalidValueError> for DecoderError {
|
||||
fn from(src: header::InvalidValueError) -> DecoderError {
|
||||
fn from(_: header::InvalidValueError) -> DecoderError {
|
||||
// TODO: Better error?
|
||||
DecoderError::InvalidUtf8
|
||||
}
|
||||
}
|
||||
|
||||
impl From<method::FromBytesError> for DecoderError {
|
||||
fn from(src: method::FromBytesError) -> DecoderError {
|
||||
fn from(_: method::FromBytesError) -> DecoderError {
|
||||
// TODO: Better error
|
||||
DecoderError::InvalidUtf8
|
||||
}
|
||||
}
|
||||
|
||||
impl From<header::FromBytesError> for DecoderError {
|
||||
fn from(src: header::FromBytesError) -> DecoderError {
|
||||
fn from(_: header::FromBytesError) -> DecoderError {
|
||||
// TODO: Better error
|
||||
DecoderError::InvalidUtf8
|
||||
}
|
||||
}
|
||||
|
||||
impl From<status::FromStrError> for DecoderError {
|
||||
fn from(src: status::FromStrError) -> DecoderError {
|
||||
fn from(_: status::FromStrError) -> DecoderError {
|
||||
// TODO: Better error
|
||||
DecoderError::InvalidUtf8
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ impl Encoder {
|
||||
self.size_update = Some(SizeUpdate::One(val));
|
||||
}
|
||||
}
|
||||
Some(SizeUpdate::Two(min, max)) => {
|
||||
Some(SizeUpdate::Two(min, _)) => {
|
||||
if val < min {
|
||||
self.size_update = Some(SizeUpdate::One(val));
|
||||
} else {
|
||||
@@ -179,7 +179,6 @@ impl Encoder {
|
||||
{
|
||||
match *index {
|
||||
Index::Indexed(idx, _) => {
|
||||
let header = self.table.resolve(&index);
|
||||
try!(encode_int(idx, 7, 0x80, dst));
|
||||
}
|
||||
Index::Name(idx, _) => {
|
||||
@@ -191,7 +190,7 @@ impl Encoder {
|
||||
header.is_sensitive(),
|
||||
dst));
|
||||
}
|
||||
Index::Inserted(idx) => {
|
||||
Index::Inserted(_) => {
|
||||
let header = self.table.resolve(&index);
|
||||
|
||||
assert!(!header.is_sensitive());
|
||||
@@ -323,14 +322,14 @@ fn encode_str(val: &[u8], dst: &mut BytesMut) -> Result<(), EncoderError> {
|
||||
|
||||
if encode_int_one_byte(huff_len, 7) {
|
||||
// Write the string head
|
||||
dst[idx] = (0x80 | huff_len as u8);
|
||||
dst[idx] = 0x80 | huff_len as u8;
|
||||
} else {
|
||||
// Write the head to a placeholer
|
||||
let mut buf = [0; 8];
|
||||
|
||||
let head_len = {
|
||||
let mut head_dst = Cursor::new(&mut buf);
|
||||
encode_int(huff_len, 7, 0x80, &mut head_dst);
|
||||
try!(encode_int(huff_len, 7, 0x80, &mut head_dst));
|
||||
head_dst.position() as usize
|
||||
};
|
||||
|
||||
@@ -407,7 +406,6 @@ fn encode_int<B: BufMut>(
|
||||
}
|
||||
|
||||
dst.put_u8(value as u8);
|
||||
rem -= 1;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::DecoderError;
|
||||
use util::byte_str::{ByteStr, FromUtf8Error};
|
||||
use util::byte_str::ByteStr;
|
||||
|
||||
use http::{Method, StatusCode};
|
||||
use http::header::{HeaderName, HeaderValue};
|
||||
@@ -104,7 +104,7 @@ impl Header {
|
||||
Header::Path(ref v) => {
|
||||
32 + 5 + v.len()
|
||||
}
|
||||
Header::Status(ref v) => {
|
||||
Header::Status(_) => {
|
||||
32 + 7 + 3
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ pub fn encode<B: BufMut>(src: &[u8], dst: &mut B) -> Result<(), EncoderError> {
|
||||
bits |= code << (bits_left - nbits);
|
||||
bits_left -= nbits;
|
||||
|
||||
while (bits_left <= 32) {
|
||||
while bits_left <= 32 {
|
||||
if rem == 0 {
|
||||
return Err(EncoderError::BufferOverflow);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use super::Header;
|
||||
|
||||
use fnv::FnvHasher;
|
||||
use http::method;
|
||||
use http::header::{self, HeaderName, HeaderValue};
|
||||
use http::{method, header};
|
||||
|
||||
use std::{cmp, mem, usize};
|
||||
use std::collections::VecDeque;
|
||||
@@ -193,7 +192,7 @@ impl Table {
|
||||
return self.index_vacant(header, hash, dist, probe, statik);
|
||||
} else if pos.hash == hash && self.slots[slot_idx].header.name() == header.name() {
|
||||
// Matching name, check values
|
||||
return self.index_occupied(header, hash, pos.index, statik);
|
||||
return self.index_occupied(header, hash, pos.index);
|
||||
}
|
||||
} else {
|
||||
return self.index_vacant(header, hash, dist, probe, statik);
|
||||
@@ -206,8 +205,7 @@ impl Table {
|
||||
fn index_occupied(&mut self,
|
||||
header: Header,
|
||||
hash: HashValue,
|
||||
mut index: usize,
|
||||
statik: Option<(usize, bool)>)
|
||||
mut index: usize)
|
||||
-> Index
|
||||
{
|
||||
debug_assert!(self.assert_valid_state("top"));
|
||||
@@ -255,8 +253,6 @@ impl Table {
|
||||
// it when inserting the new one...
|
||||
return Index::InsertedValue(real_idx + DYN_OFFSET, 0);
|
||||
}
|
||||
|
||||
Index::NotIndexed(header)
|
||||
}
|
||||
|
||||
fn index_vacant(&mut self,
|
||||
@@ -302,7 +298,7 @@ impl Table {
|
||||
|
||||
let pos_idx = 0usize.wrapping_sub(self.inserted);
|
||||
|
||||
let mut prev = mem::replace(&mut self.indices[probe], Some(Pos {
|
||||
let prev = mem::replace(&mut self.indices[probe], Some(Pos {
|
||||
index: pos_idx,
|
||||
hash: hash,
|
||||
}));
|
||||
@@ -513,9 +509,15 @@ impl Table {
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks that the internal map state is correct
|
||||
#[cfg(not(test))]
|
||||
fn assert_valid_state(&self, _: &'static str) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn assert_valid_state(&self, msg: &'static str) -> bool {
|
||||
/*
|
||||
// Checks that the internal map structure is valid
|
||||
//
|
||||
// Ensure all hash codes in indices match the associated slot
|
||||
for pos in &self.indices {
|
||||
if let Some(pos) = *pos {
|
||||
@@ -596,7 +598,6 @@ impl Table {
|
||||
}
|
||||
|
||||
// TODO: Ensure linked lists are correct: no cycles, etc...
|
||||
*/
|
||||
|
||||
true
|
||||
}
|
||||
@@ -715,7 +716,7 @@ fn index_static(header: &Header) -> Option<(usize, bool)> {
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
Header::Authority(ref v) => Some((1, false)),
|
||||
Header::Authority(_) => Some((1, false)),
|
||||
Header::Method(ref v) => {
|
||||
match *v {
|
||||
method::GET => Some((2, true)),
|
||||
|
||||
Reference in New Issue
Block a user