fix(lib): Fixed typos in multiple modules
BREAKING CHANGE: The `Preference` header had a typo in a variant and it's string representation, change `Preference::HandlingLeniant` to `Preference::HandlingLenient`.
This commit is contained in:
committed by
Sean McArthur
parent
0d05533d07
commit
2fa414fb5f
@@ -88,7 +88,7 @@ impl Display for AccessControlAllowOrigin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_access_control_allow_orgin {
|
mod test_access_control_allow_origin {
|
||||||
use header::*;
|
use header::*;
|
||||||
use super::AccessControlAllowOrigin as HeaderField;
|
use super::AccessControlAllowOrigin as HeaderField;
|
||||||
test_header!(test1, vec![b"null"]);
|
test_header!(test1, vec![b"null"]);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ header! {
|
|||||||
/// [RFC7231](https://tools.ietf.org/html/rfc7231#section-3.1.4.2)
|
/// [RFC7231](https://tools.ietf.org/html/rfc7231#section-3.1.4.2)
|
||||||
///
|
///
|
||||||
/// The header can be used by both the client in requests and the server
|
/// The header can be used by both the client in requests and the server
|
||||||
/// in resposes with different semantics. Client sets `Content-Location`
|
/// in responses with different semantics. Client sets `Content-Location`
|
||||||
/// to refer to the URI where original representation of the body was
|
/// to refer to the URI where original representation of the body was
|
||||||
/// obtained.
|
/// obtained.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ header! {
|
|||||||
/// track of event state. This is helpful when working
|
/// track of event state. This is helpful when working
|
||||||
/// with [Server-Sent-Events](http://www.html5rocks.com/en/tutorials/eventsource/basics/). If the connection were to be dropped, for example, it'd
|
/// with [Server-Sent-Events](http://www.html5rocks.com/en/tutorials/eventsource/basics/). If the connection were to be dropped, for example, it'd
|
||||||
/// be useful to let the server know what the last event you
|
/// be useful to let the server know what the last event you
|
||||||
/// recieved was.
|
/// received was.
|
||||||
///
|
///
|
||||||
/// The spec is a String with the id of the last event, it can be
|
/// The spec is a String with the id of the last event, it can be
|
||||||
/// an empty string which acts a sort of "reset".
|
/// an empty string which acts a sort of "reset".
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ impl FromStr for Origin {
|
|||||||
Some(idx) => idx,
|
Some(idx) => idx,
|
||||||
None => return Err(::Error::Header)
|
None => return Err(::Error::Header)
|
||||||
};
|
};
|
||||||
// idx + 3 because thats how long "://" is
|
// idx + 3 because that's how long "://" is
|
||||||
let (scheme, etc) = (&s[..idx], &s[idx + 3..]);
|
let (scheme, etc) = (&s[..idx], &s[idx + 3..]);
|
||||||
let host = try!(Host::from_str(etc));
|
let host = try!(Host::from_str(etc));
|
||||||
|
|
||||||
|
|||||||
@@ -87,8 +87,8 @@ pub enum Preference {
|
|||||||
ReturnMinimal,
|
ReturnMinimal,
|
||||||
/// "handling=strict"
|
/// "handling=strict"
|
||||||
HandlingStrict,
|
HandlingStrict,
|
||||||
/// "handling=leniant"
|
/// "handling=lenient"
|
||||||
HandlingLeniant,
|
HandlingLenient,
|
||||||
/// "wait=delta"
|
/// "wait=delta"
|
||||||
Wait(u32),
|
Wait(u32),
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ impl fmt::Display for Preference {
|
|||||||
ReturnRepresentation => "return=representation",
|
ReturnRepresentation => "return=representation",
|
||||||
ReturnMinimal => "return=minimal",
|
ReturnMinimal => "return=minimal",
|
||||||
HandlingStrict => "handling=strict",
|
HandlingStrict => "handling=strict",
|
||||||
HandlingLeniant => "handling=leniant",
|
HandlingLenient => "handling=lenient",
|
||||||
|
|
||||||
Wait(secs) => return write!(f, "wait={}", secs),
|
Wait(secs) => return write!(f, "wait={}", secs),
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ impl FromStr for Preference {
|
|||||||
("return", "representation") => if rest.is_empty() { Ok(ReturnRepresentation) } else { Err(None) },
|
("return", "representation") => if rest.is_empty() { Ok(ReturnRepresentation) } else { Err(None) },
|
||||||
("return", "minimal") => if rest.is_empty() { Ok(ReturnMinimal) } else { Err(None) },
|
("return", "minimal") => if rest.is_empty() { Ok(ReturnMinimal) } else { Err(None) },
|
||||||
("handling", "strict") => if rest.is_empty() { Ok(HandlingStrict) } else { Err(None) },
|
("handling", "strict") => if rest.is_empty() { Ok(HandlingStrict) } else { Err(None) },
|
||||||
("handling", "leniant") => if rest.is_empty() { Ok(HandlingLeniant) } else { Err(None) },
|
("handling", "lenient") => if rest.is_empty() { Ok(HandlingLenient) } else { Err(None) },
|
||||||
("wait", secs) => if rest.is_empty() { secs.parse().map(Wait).map_err(Some) } else { Err(None) },
|
("wait", secs) => if rest.is_empty() { secs.parse().map(Wait).map_err(Some) } else { Err(None) },
|
||||||
(left, right) => Ok(Extension(left.to_owned(), right.to_owned(), rest))
|
(left, right) => Ok(Extension(left.to_owned(), right.to_owned(), rest))
|
||||||
}
|
}
|
||||||
@@ -172,9 +172,9 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parse_argument() {
|
fn test_parse_argument() {
|
||||||
let prefer = Header::parse_header(&"wait=100, handling=leniant, respond-async".into());
|
let prefer = Header::parse_header(&"wait=100, handling=lenient, respond-async".into());
|
||||||
assert_eq!(prefer.ok(), Some(Prefer(vec![Preference::Wait(100),
|
assert_eq!(prefer.ok(), Some(Prefer(vec![Preference::Wait(100),
|
||||||
Preference::HandlingLeniant,
|
Preference::HandlingLenient,
|
||||||
Preference::RespondAsync])))
|
Preference::RespondAsync])))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ header! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A protocol name used to identify a spefic protocol. Names are case-sensitive
|
/// A protocol name used to identify a specific protocol. Names are case-sensitive
|
||||||
/// except for the `WebSocket` value.
|
/// except for the `WebSocket` value.
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub enum ProtocolName {
|
pub enum ProtocolName {
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ fn from_f32(f: f32) -> Quality {
|
|||||||
Quality((f * 1000f32) as u16)
|
Quality((f * 1000f32) as u16)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convinience function to wrap a value in a `QualityItem`
|
/// Convenience function to wrap a value in a `QualityItem`
|
||||||
/// Sets `q` to the default 1.0
|
/// Sets `q` to the default 1.0
|
||||||
pub fn qitem<T>(item: T) -> QualityItem<T> {
|
pub fn qitem<T>(item: T) -> QualityItem<T> {
|
||||||
QualityItem::new(item, Default::default())
|
QualityItem::new(item, Default::default())
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ impl MemBuf {
|
|||||||
grow_zerofill(vec, needed);
|
grow_zerofill(vec, needed);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// we need to allocate more space, but dont have unique
|
// we need to allocate more space, but don't have unique
|
||||||
// access, so we need to make a new buffer
|
// access, so we need to make a new buffer
|
||||||
trace!("MemBuf::reserve shared buffer, creating new");
|
trace!("MemBuf::reserve shared buffer, creating new");
|
||||||
let mut new = MemBuf::with_capacity(needed);
|
let mut new = MemBuf::with_capacity(needed);
|
||||||
|
|||||||
@@ -524,7 +524,7 @@ impl<K: KeepAlive> State<K> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The DebugFrame and DebugChunk are simple Debug implementations that allow
|
// The DebugFrame and DebugChunk are simple Debug implementations that allow
|
||||||
// us to dump the frame into logs, wihtout logging the entirety of the bytes.
|
// us to dump the frame into logs, without logging the entirety of the bytes.
|
||||||
struct DebugFrame<'a, T: fmt::Debug + 'a>(&'a Frame<http::MessageHead<T>, http::Chunk, ::Error>);
|
struct DebugFrame<'a, T: fmt::Debug + 'a>(&'a Frame<http::MessageHead<T>, http::Chunk, ::Error>);
|
||||||
|
|
||||||
impl<'a, T: fmt::Debug + 'a> fmt::Debug for DebugFrame<'a, T> {
|
impl<'a, T: fmt::Debug + 'a> fmt::Debug for DebugFrame<'a, T> {
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ impl HttpMessage for Http11Message {
|
|||||||
let is_empty = !should_have_response_body(&method, raw_status.0);
|
let is_empty = !should_have_response_body(&method, raw_status.0);
|
||||||
stream.get_mut().set_previous_response_expected_no_content(is_empty);
|
stream.get_mut().set_previous_response_expected_no_content(is_empty);
|
||||||
// According to https://tools.ietf.org/html/rfc7230#section-3.3.3
|
// According to https://tools.ietf.org/html/rfc7230#section-3.3.3
|
||||||
// 1. HEAD reponses, and Status 1xx, 204, and 304 cannot have a body.
|
// 1. HEAD responses, and Status 1xx, 204, and 304 cannot have a body.
|
||||||
// 2. Status 2xx to a CONNECT cannot have a body.
|
// 2. Status 2xx to a CONNECT cannot have a body.
|
||||||
// 3. Transfer-Encoding: chunked has a chunked body.
|
// 3. Transfer-Encoding: chunked has a chunked body.
|
||||||
// 4. If multiple differing Content-Length headers or invalid, close connection.
|
// 4. If multiple differing Content-Length headers or invalid, close connection.
|
||||||
@@ -86,7 +86,7 @@ impl HttpMessage for Http11Message {
|
|||||||
if codings.last() == Some(&Chunked) {
|
if codings.last() == Some(&Chunked) {
|
||||||
ChunkedReader(stream, None)
|
ChunkedReader(stream, None)
|
||||||
} else {
|
} else {
|
||||||
trace!("not chuncked. read till eof");
|
trace!("not chunked. read till eof");
|
||||||
EofReader(stream)
|
EofReader(stream)
|
||||||
}
|
}
|
||||||
} else if let Some(&ContentLength(len)) = headers.get() {
|
} else if let Some(&ContentLength(len)) = headers.get() {
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ impl Http1Transaction for ClientTransaction {
|
|||||||
fn decoder(inc: &MessageHead<Self::Incoming>) -> ::Result<Decoder> {
|
fn decoder(inc: &MessageHead<Self::Incoming>) -> ::Result<Decoder> {
|
||||||
use ::header;
|
use ::header;
|
||||||
// According to https://tools.ietf.org/html/rfc7230#section-3.3.3
|
// According to https://tools.ietf.org/html/rfc7230#section-3.3.3
|
||||||
// 1. HEAD reponses, and Status 1xx, 204, and 304 cannot have a body.
|
// 1. HEAD responses, and Status 1xx, 204, and 304 cannot have a body.
|
||||||
// 2. Status 2xx to a CONNECT cannot have a body.
|
// 2. Status 2xx to a CONNECT cannot have a body.
|
||||||
//
|
//
|
||||||
// First two steps taken care of before this method.
|
// First two steps taken care of before this method.
|
||||||
@@ -164,7 +164,7 @@ impl Http1Transaction for ClientTransaction {
|
|||||||
if codings.last() == Some(&header::Encoding::Chunked) {
|
if codings.last() == Some(&header::Encoding::Chunked) {
|
||||||
Ok(Decoder::chunked())
|
Ok(Decoder::chunked())
|
||||||
} else {
|
} else {
|
||||||
trace!("not chuncked. read till eof");
|
trace!("not chunked. read till eof");
|
||||||
Ok(Decoder::eof())
|
Ok(Decoder::eof())
|
||||||
}
|
}
|
||||||
} else if let Some(&header::ContentLength(len)) = inc.headers.get() {
|
} else if let Some(&header::ContentLength(len)) = inc.headers.get() {
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ fn client_keep_alive() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* TODO: re-enable once rety works, its currently a flaky test
|
/* TODO: re-enable once retry works, its currently a flaky test
|
||||||
#[test]
|
#[test]
|
||||||
fn client_pooled_socket_disconnected() {
|
fn client_pooled_socket_disconnected() {
|
||||||
let _ = pretty_env_logger::init();
|
let _ = pretty_env_logger::init();
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ fn server_get_with_body() {
|
|||||||
").unwrap();
|
").unwrap();
|
||||||
req.read(&mut [0; 256]).unwrap();
|
req.read(&mut [0; 256]).unwrap();
|
||||||
|
|
||||||
// note: doesnt include trailing \r\n, cause Content-Length wasn't 21
|
// note: doesn't include trailing \r\n, cause Content-Length wasn't 21
|
||||||
assert_eq!(server.body(), b"I'm a good request.");
|
assert_eq!(server.body(), b"I'm a good request.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user