Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit e909dfb

Browse files
committed
Merge pull request #38 from kmcallister/for-upstream
Fixes for request path handling
2 parents fd59420 + 824cb95 commit e909dfb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/libhttp/client/request.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ that's due to a Rust bug; when that's resolved, we'll go back to using just `Req
4040
*/
4141

4242
use extra::url::Url;
43+
use extra::url;
4344
use method::Method;
4445
use std::rt::io::{Reader, Writer};
4546
use std::rt::io::net::get_host_addresses;
@@ -203,8 +204,11 @@ impl RequestWriter<TcpStream> {
203204
// TODO: get to the point where we can say HTTP/1.1 with good conscience
204205
// XXX: Rust's current lack of statement-duration lifetime handling prevents this from being
205206
// one statement ("error: borrowed value does not live long enough")
206-
// TODO: don't send the entire URL; just url.{path, query}
207-
let s = format!("{} {} HTTP/1.0\r\n", self.method.to_str(), self.url.to_str());
207+
let s = format!("{} {}{}{} HTTP/1.0\r\n",
208+
self.method.to_str(),
209+
if self.url.path.len() > 0 { self.url.path.as_slice() } else { "/" },
210+
if self.url.query.len() > 0 { "?" } else { "" },
211+
url::query_to_str(&self.url.query));
208212
self.stream.write(s.as_bytes());
209213

210214
self.headers.write_all(&mut self.stream);

0 commit comments

Comments
 (0)