refactor(headers): export all headers and utils directly under header
Currently headers are exported at many places. For example you can access `Transfer-Encoding` header at `header`, `header::common` and `header::common::transfer_encoding`. Per discussion on IRC with @seanmonstar and @reem, all contents of headers will be exposed at `header` directly. Parsing utilities will be exposed at `header::parsing`. Header macros can now be used from other crates. This breaks much code using headers. It should use everything it needs directly from `header::`, encodings are exposed at `header::Encoding::`, connection options are exposed at `header::ConnectionOption`.
This commit is contained in:
		| @@ -26,7 +26,7 @@ use url::UrlParser; | ||||
| use url::ParseError as UrlError; | ||||
|  | ||||
| use header::{Headers, Header, HeaderFormat}; | ||||
| use header::common::{ContentLength, Location}; | ||||
| use header::{ContentLength, Location}; | ||||
| use method::Method; | ||||
| use net::{NetworkConnector, HttpConnector, ContextVerifier}; | ||||
| use status::StatusClass::Redirection; | ||||
| @@ -353,7 +353,7 @@ fn get_host_and_port(url: &Url) -> HttpResult<(String, Port)> { | ||||
|  | ||||
| #[cfg(test)] | ||||
| mod tests { | ||||
|     use header::common::Server; | ||||
|     use header::Server; | ||||
|     use super::{Client, RedirectPolicy}; | ||||
|     use url::Url; | ||||
|  | ||||
|   | ||||
| @@ -5,7 +5,7 @@ use url::Url; | ||||
|  | ||||
| use method::{self, Method}; | ||||
| use header::Headers; | ||||
| use header::common::{self, Host}; | ||||
| use header::{self, Host}; | ||||
| use net::{NetworkStream, NetworkConnector, HttpConnector, Fresh, Streaming}; | ||||
| use http::{HttpWriter, LINE_ENDING}; | ||||
| use http::HttpWriter::{ThroughWriter, ChunkedWriter, SizedWriter, EmptyWriter}; | ||||
| @@ -95,7 +95,7 @@ impl Request<Fresh> { | ||||
|                 let mut chunked = true; | ||||
|                 let mut len = 0; | ||||
|  | ||||
|                 match self.headers.get::<common::ContentLength>() { | ||||
|                 match self.headers.get::<header::ContentLength>() { | ||||
|                     Some(cl) => { | ||||
|                         chunked = false; | ||||
|                         len = **cl; | ||||
| @@ -105,18 +105,18 @@ impl Request<Fresh> { | ||||
|  | ||||
|                 // cant do in match above, thanks borrowck | ||||
|                 if chunked { | ||||
|                     let encodings = match self.headers.get_mut::<common::TransferEncoding>() { | ||||
|                         Some(&mut common::TransferEncoding(ref mut encodings)) => { | ||||
|                     let encodings = match self.headers.get_mut::<header::TransferEncoding>() { | ||||
|                         Some(&mut header::TransferEncoding(ref mut encodings)) => { | ||||
|                             //TODO: check if chunked is already in encodings. use HashSet? | ||||
|                             encodings.push(common::transfer_encoding::Encoding::Chunked); | ||||
|                             encodings.push(header::Encoding::Chunked); | ||||
|                             false | ||||
|                         }, | ||||
|                         None => true | ||||
|                     }; | ||||
|  | ||||
|                     if encodings { | ||||
|                         self.headers.set::<common::TransferEncoding>( | ||||
|                             common::TransferEncoding(vec![common::transfer_encoding::Encoding::Chunked])) | ||||
|                         self.headers.set::<header::TransferEncoding>( | ||||
|                             header::TransferEncoding(vec![header::Encoding::Chunked])) | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
|   | ||||
| @@ -3,8 +3,8 @@ use std::num::FromPrimitive; | ||||
| use std::io::{BufferedReader, IoResult}; | ||||
|  | ||||
| use header; | ||||
| use header::common::{ContentLength, TransferEncoding}; | ||||
| use header::common::transfer_encoding::Encoding::Chunked; | ||||
| use header::{ContentLength, TransferEncoding}; | ||||
| use header::Encoding::Chunked; | ||||
| use net::{NetworkStream, HttpStream}; | ||||
| use http::{read_status_line, HttpReader, RawStatus}; | ||||
| use http::HttpReader::{SizedReader, ChunkedReader, EofReader}; | ||||
| @@ -100,8 +100,8 @@ mod tests { | ||||
|     use std::io::BufferedReader; | ||||
|  | ||||
|     use header::Headers; | ||||
|     use header::common::TransferEncoding; | ||||
|     use header::common::transfer_encoding::Encoding; | ||||
|     use header::TransferEncoding; | ||||
|     use header::Encoding; | ||||
|     use http::HttpReader::EofReader; | ||||
|     use http::RawStatus; | ||||
|     use mock::MockStream; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user