Skip to content

Commit 2701405

Browse files
committed
Send only the path and the query when making HTTP requests
1 parent c450d46 commit 2701405

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/libhttp/client/request.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,15 @@ impl RequestWriter<TcpStream> {
203203
// TODO: get to the point where we can say HTTP/1.1 with good conscience
204204
// XXX: Rust's current lack of statement-duration lifetime handling prevents this from being
205205
// 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());
206+
let s = format!("{} {}{}{} HTTP/1.0\r\n",
207+
self.method.to_str(),
208+
self.url.path,
209+
if self.url.query.len() > 0 {
210+
"?"
211+
} else {
212+
""
213+
},
214+
self.url.query.to_str());
208215
self.stream.write(s.as_bytes());
209216

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

0 commit comments

Comments
 (0)