feat(server): add path() and query() to Request

Closes #896 
Closes #897

BREAKING CHANGE: `RequestUri::AbsolutePath` variant is changed to a struct variant. Consider using `req.path()` or `req.query()` to get the relevant slice.
This commit is contained in:
Ahmed Charles
2016-08-29 13:45:38 -07:00
committed by Sean McArthur
parent a228486a85
commit 8b3c120684
6 changed files with 63 additions and 24 deletions

View File

@@ -290,7 +290,6 @@ impl<H: Handler<T>, T: Transport> http::MessageHandler<T> for Message<H, T> {
type Message = http::ClientMessage;
fn on_outgoing(&mut self, head: &mut RequestHead) -> Next {
use ::url::Position;
let url = self.url.take().expect("Message.url is missing");
if let Some(host) = url.host_str() {
head.headers.set(Host {
@@ -298,7 +297,10 @@ impl<H: Handler<T>, T: Transport> http::MessageHandler<T> for Message<H, T> {
port: url.port(),
});
}
head.subject.1 = RequestUri::AbsolutePath(url[Position::BeforePath..Position::AfterQuery].to_owned());
head.subject.1 = RequestUri::AbsolutePath {
path: url.path().to_owned(),
query: url.query().map(|q| q.to_owned()),
};
let mut req = self::request::new(head);
self.handler.on_request(&mut req)
}