-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust up for nightly #236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rust up for nightly #236
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| #![allow(unstable)] | ||
| extern crate hyper; | ||
| extern crate test; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| #![allow(unstable)] | ||
| extern crate hyper; | ||
|
|
||
| use std::os; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| #![allow(unstable)] | ||
| extern crate hyper; | ||
|
|
||
| use std::io::net::ip::Ipv4Addr; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,8 +3,7 @@ use std::io::{BufferedWriter, IoResult}; | |
|
|
||
| use url::Url; | ||
|
|
||
| use method; | ||
| use method::Method::{Get, Post, Delete, Put, Patch, Head, Options}; | ||
| use method::{self, Method}; | ||
| use header::Headers; | ||
| use header::common::{self, Host}; | ||
| use net::{NetworkStream, NetworkConnector, HttpConnector, Fresh, Streaming}; | ||
|
|
@@ -46,11 +45,14 @@ impl Request<Fresh> { | |
| } | ||
|
|
||
| /// Create a new client request with a specific underlying NetworkStream. | ||
| pub fn with_connector<C: NetworkConnector<S>, S: NetworkStream>(method: method::Method, url: Url, connector: &mut C) -> HttpResult<Request<Fresh>> { | ||
| debug!("{:?} {:?}", method, url); | ||
| pub fn with_connector<C, S>(method: method::Method, url: Url, connector: &mut C) | ||
| -> HttpResult<Request<Fresh>> where | ||
| C: NetworkConnector<Stream=S>, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use a where clause instead, it's much cleaner. (for all these params)
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see how it much cleaner, it looks the same to me except one is before the parens, one is after. But I moved it cause people seem to like it. |
||
| S: NetworkStream + Send { | ||
| debug!("{} {}", method, url); | ||
| let (host, port) = try!(get_host_and_port(&url)); | ||
|
|
||
| let stream: S = try!(connector.connect(&host[], port, &*url.scheme)); | ||
| let stream = try!(connector.connect(&*host, port, &*url.scheme)); | ||
| let stream = ThroughWriter(BufferedWriter::new(box stream as Box<NetworkStream + Send>)); | ||
|
|
||
| let mut headers = Headers::new(); | ||
|
|
@@ -68,41 +70,6 @@ impl Request<Fresh> { | |
| }) | ||
| } | ||
|
|
||
| /// Create a new GET request. | ||
| #[inline] | ||
| #[deprecated = "use hyper::Client"] | ||
| pub fn get(url: Url) -> HttpResult<Request<Fresh>> { Request::new(Get, url) } | ||
|
|
||
| /// Create a new POST request. | ||
| #[inline] | ||
| #[deprecated = "use hyper::Client"] | ||
| pub fn post(url: Url) -> HttpResult<Request<Fresh>> { Request::new(Post, url) } | ||
|
|
||
| /// Create a new DELETE request. | ||
| #[inline] | ||
| #[deprecated = "use hyper::Client"] | ||
| pub fn delete(url: Url) -> HttpResult<Request<Fresh>> { Request::new(Delete, url) } | ||
|
|
||
| /// Create a new PUT request. | ||
| #[inline] | ||
| #[deprecated = "use hyper::Client"] | ||
| pub fn put(url: Url) -> HttpResult<Request<Fresh>> { Request::new(Put, url) } | ||
|
|
||
| /// Create a new PATCH request. | ||
| #[inline] | ||
| #[deprecated = "use hyper::Client"] | ||
| pub fn patch(url: Url) -> HttpResult<Request<Fresh>> { Request::new(Patch, url) } | ||
|
|
||
| /// Create a new HEAD request. | ||
| #[inline] | ||
| #[deprecated = "use hyper::Client"] | ||
| pub fn head(url: Url) -> HttpResult<Request<Fresh>> { Request::new(Head, url) } | ||
|
|
||
| /// Create a new OPTIONS request. | ||
| #[inline] | ||
| #[deprecated = "use hyper::Client"] | ||
| pub fn options(url: Url) -> HttpResult<Request<Fresh>> { Request::new(Options, url) } | ||
|
|
||
| /// Consume a Fresh Request, writing the headers and method, | ||
| /// returning a Streaming Request. | ||
| pub fn start(mut self) -> HttpResult<Request<Streaming>> { | ||
|
|
@@ -119,7 +86,7 @@ impl Request<Fresh> { | |
|
|
||
|
|
||
| let stream = match self.method { | ||
| Get | Head => { | ||
| Method::Get | Method::Head => { | ||
| debug!("headers [\n{:?}]", self.headers); | ||
| try!(write!(&mut self.body, "{}{}", self.headers, LINE_ENDING)); | ||
| EmptyWriter(self.body.unwrap()) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this really be u64 and not usize?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. It could be from an fstat. usize on 32bit system will limit you to files less than 4gb.