refactor(hyper): Update to rust-url 1.0
BREAKING CHANGE: The re-exported Url type has breaking changes.
This commit is contained in:
		
				
					committed by
					
						 Sean McArthur
						Sean McArthur
					
				
			
			
				
	
			
			
			
						parent
						
							4bdf52a482
						
					
				
				
					commit
					8fa7a98968
				
			| @@ -7,6 +7,7 @@ use std::net::Shutdown; | ||||
| use std::time::Duration; | ||||
|  | ||||
| use httparse; | ||||
| use url::Position as UrlPosition; | ||||
|  | ||||
| use buffer::BufReader; | ||||
| use Error; | ||||
| @@ -142,24 +143,22 @@ impl HttpMessage for Http11Message { | ||||
|             }; | ||||
|             let mut stream = BufWriter::new(stream); | ||||
|  | ||||
|             let mut uri = head.url.serialize_path().unwrap(); | ||||
|             if let Some(ref q) = head.url.query { | ||||
|                 uri.push('?'); | ||||
|                 uri.push_str(&q[..]); | ||||
|             } | ||||
|             { | ||||
|                 let uri = &head.url[UrlPosition::BeforePath..UrlPosition::AfterQuery]; | ||||
|  | ||||
|             let version = version::HttpVersion::Http11; | ||||
|             debug!("request line: {:?} {:?} {:?}", head.method, uri, version); | ||||
|             match write!(&mut stream, "{} {} {}{}", | ||||
|                          head.method, uri, version, LINE_ENDING) { | ||||
|                              Err(e) => { | ||||
|                                  res = Err(From::from(e)); | ||||
|                                  // TODO What should we do if the BufWriter doesn't wanna | ||||
|                                  // relinquish the stream? | ||||
|                                  return Stream::Idle(stream.into_inner().ok().unwrap()); | ||||
|                              }, | ||||
|                              Ok(_) => {}, | ||||
|                          }; | ||||
|                 let version = version::HttpVersion::Http11; | ||||
|                 debug!("request line: {:?} {:?} {:?}", head.method, uri, version); | ||||
|                 match write!(&mut stream, "{} {} {}{}", | ||||
|                              head.method, uri, version, LINE_ENDING) { | ||||
|                                  Err(e) => { | ||||
|                                      res = Err(From::from(e)); | ||||
|                                      // TODO What should we do if the BufWriter doesn't wanna | ||||
|                                      // relinquish the stream? | ||||
|                                      return Stream::Idle(stream.into_inner().ok().unwrap()); | ||||
|                                  }, | ||||
|                                  Ok(_) => {}, | ||||
|                              }; | ||||
|             } | ||||
|  | ||||
|             let stream = { | ||||
|                 let write_headers = |mut stream: BufWriter<Box<NetworkStream + Send>>, head: &RequestHead| { | ||||
|   | ||||
| @@ -15,7 +15,7 @@ use http::{ | ||||
| }; | ||||
| use net::{NetworkStream, NetworkConnector}; | ||||
| use net::{HttpConnector, HttpStream}; | ||||
| use url::Url; | ||||
| use url::Position as UrlPosition; | ||||
| use header::Headers; | ||||
|  | ||||
| use header; | ||||
| @@ -262,16 +262,6 @@ impl<S> Read for Http2Message<S> where S: CloneableStream { | ||||
|     } | ||||
| } | ||||
|  | ||||
| /// A helper function that prepares the path of a request by extracting it from the given `Url`. | ||||
| fn prepare_path(url: Url) -> Vec<u8> { | ||||
|     let mut uri = url.serialize_path().unwrap(); | ||||
|     if let Some(ref q) = url.query { | ||||
|         uri.push('?'); | ||||
|         uri.push_str(&q[..]); | ||||
|     } | ||||
|     uri.into_bytes() | ||||
| } | ||||
|  | ||||
| /// A helper function that prepares the headers that should be sent in an HTTP/2 message. | ||||
| /// | ||||
| /// Adapts the `Headers` into a list of octet string pairs. | ||||
| @@ -374,7 +364,7 @@ impl<S> HttpMessage for Http2Message<S> where S: CloneableStream { | ||||
|         let (RequestHead { headers, method, url }, body) = (request.head, request.body); | ||||
|  | ||||
|         let method = method.as_ref().as_bytes(); | ||||
|         let path = prepare_path(url); | ||||
|         let path = url[UrlPosition::BeforePath..UrlPosition::AfterQuery].as_bytes(); | ||||
|         let extra_headers = prepare_headers(headers); | ||||
|         let body = prepare_body(body); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user