committed by
					
						 Sean McArthur
						Sean McArthur
					
				
			
			
				
	
			
			
			
						parent
						
							50a6f6103e
						
					
				
				
					commit
					224cc709c3
				
			| @@ -59,7 +59,7 @@ impl Request<Fresh> { | ||||
|         let stream: S = try_io!(NetworkStream::connect(host.as_slice(), port, url.scheme.as_slice())); | ||||
|         let stream = ThroughWriter(BufferedWriter::new(stream.dynamic())); | ||||
|         let mut headers = Headers::new(); | ||||
|         headers.set(Host(host)); | ||||
|         headers.set(Host(format!("{}:{}", host, port))); | ||||
|  | ||||
|         Ok(Request { | ||||
|             method: method, | ||||
| @@ -187,3 +187,33 @@ impl Writer for Request<Streaming> { | ||||
|         self.body.flush() | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
| #[cfg(test)] | ||||
| mod tests { | ||||
|     use header::common::Host; | ||||
|     use method::Get; | ||||
|     use net::MockStream; | ||||
|     use url::Url; | ||||
|     use super::Request; | ||||
|  | ||||
|  | ||||
|     #[test] | ||||
|     fn test_host_header() { | ||||
|         fn check_host(url: &str, host_header: &str) { | ||||
|             let request = Request::with_stream::<MockStream>( | ||||
|                 Get, | ||||
|                 Url::parse(url).unwrap(), | ||||
|             ).unwrap(); | ||||
|  | ||||
|             assert_eq!( | ||||
|                 &Host(host_header.to_string()), | ||||
|                 request.headers().get::<Host>().unwrap() | ||||
|             ); | ||||
|         } | ||||
|  | ||||
|         check_host("http://www.example.com/path", "www.example.com:80"); | ||||
|         check_host("https://www.example.com/path", "www.example.com:443"); | ||||
|         check_host("http://www.example.com:8080/path", "www.example.com:8080"); | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user