Commit Graph

40 Commits

Author SHA1 Message Date
Utkarsh Kukreti
559f21a664 fix(uri): fix parse for empty path and '/' or '?' in fragment
Fixes #1176.
2017-05-17 17:09:20 +05:30
Sean McArthur
154ab29c0d feat(uri): add is_absolute method to Uri
This allows servers to check if an incoming URI is in absolute form.
Especially useful for proxies to determine if the request was meant to
be proxied or aimed directly at the proxy server.
2017-05-01 12:29:06 -07:00
Sean McArthur
6dd76a6839 perf(uri): inline Uri getters 2017-04-24 12:08:48 -07:00
Sean McArthur
f05a58a1b2 chore(travis): set minimum rust version 2017-04-10 15:09:54 -07:00
Sean McArthur
5d3499e036 fix(uri): fix Uri to origin_form when path is '*' 2017-04-05 14:36:39 -07:00
Sean McArthur
cb1927553e fix(uri): fix Uri to_origin_form to always include '/'
Closes #1112
2017-04-05 11:40:57 -07:00
Sean McArthur
1b49237e27 fix(uri): fix Uri.path() from containing '?' ever
Closes #1113
2017-04-05 09:57:12 -07:00
Sean McArthur
4fb7e6ebc6 feat(lib): remove extern Url type usage
BREAKING CHANGE: The `Url` type is no longer used. Any instance in the
  `Client` API has had it replaced with `hyper::Uri`.

  This also means `Error::Uri` has changed types to
  `hyper::error::UriError`.

  The type `hyper::header::parsing::HTTP_VALUE` has been made private,
  as an implementation detail. The function `http_percent_encoding`
  should be used instead.
2017-03-21 11:03:57 -07:00
Sean McArthur
65b3e08f69 feat(http): use the bytes crate for Chunk and internally 2017-03-01 14:15:47 -08:00
sinkuu
8ba1f19d61 fix(url): fix panic when questionmark is in fragment 2017-02-25 20:25:39 +09:00
Michael Zapata
31d998078d docs(uri): fix rendering errors
Add a code block around the URI explanation to make it legible and
add a missing backquote
2017-02-10 16:00:59 +01:00
Guillaume Gomez
524f65a9a3 perf(header): Make Uri use MemSlice internally 2017-02-09 11:45:55 -08:00
Sean McArthur
fc808ef9f8 Merge pull request #1049 from spk/use-pub-hyper-url
test(lib): use public hyper::Url everywhere
2017-02-05 14:47:34 -08:00
Laurent Arnoud
70a3f76a27 test(uri): fix URI parse error tests
Add also test parse authority without port
2017-02-05 13:12:03 +01:00
Laurent Arnoud
d5ff287b35 refactor(lib): use public hyper::Url everywhere 2017-02-04 14:51:14 +01:00
Andy Moran
18bcc4e047 refactor(uri): Remove vec in uri parsing
Remove vec allocations in uri parsing. Additionally, change tests
to check the port.

https://github.com/hyperium/hyper/issues/1029
2017-01-23 22:35:50 +00:00
M3rs
04560dfe24 refactor(uri): Improve parse_authority safety
Improve parse_authority safety with match, replace unwrap.

Also, refactor code in contains("://") block using result from the
parse_authority to also use match.

https://github.com/hyperium/hyper/issues/1022
2017-01-23 12:26:08 -06:00
M3rs
8faf5b8bb1 refactor(uri): Add errors to scheme uri
Add errors to scheme uri (contains "://").

Check for:
- Valid schemes (ftp, gopher, http, https, ws, wss)
- Invalid schemes (blob, file), or anything else -> Err(Error::Method)
- Authority is not empty (i.e. "http://")

https://github.com/hyperium/hyper/issues/1022
2017-01-22 11:38:45 -06:00
M3rs
37b26e21e8 refactor(uri): Add default path for absolute-form
Add default path ("/") for absolute-form, even if not included.

This change assumes self.scheme().is_some() indicates that the Uri
is in absolute-form.

Issue:
https://github.com/hyperium/hyper/issues/1022
2017-01-22 10:51:06 -06:00
M3rs
55d13a9afd refactor(uri): Remove extra authority logic
Remove extra logic in authority getter method which handles
default ports.
2017-01-21 21:20:24 -06:00
M3rs
4f5327afd4 refactor(uri): Remove Url parse
Remove usage of Url parse in Uri in order to improve performance.

https://github.com/hyperium/hyper/issues/1022
2017-01-20 23:41:09 -06:00
Florent Monjalet
594ea65420 fix(uri): fix panic when uri contain default port
Parsing "http://host:80" caused panic (index out of bound) because the
authority end index was computed with the original uri but the uri
stored for later used was sanitized by `Url::parse()` to "http://host"

The fix computes the autority end index with the actual uri used (the
one from `Url::parse()`). Two tests have been added.
2017-01-20 17:17:33 +01:00
Guillaume Gomez
9036443e6b feat(uri): redesign RequestUri type into Uri
Closes #1000

BREAKING CHANGE: The name of `RequestUri` has changed to `Uri`. It is no
  longer an `enum`, but an opaque struct with getter methods.
2017-01-17 16:46:24 -08:00
Sean McArthur
2d2d5574a6 feat(lib): redesign API to use Futures and Tokio
There are many changes involved with this, but let's just talk about
user-facing changes.

- Creating a `Client` and `Server` now needs a Tokio `Core` event loop
to attach to.
- `Request` and `Response` both no longer implement the
`std::io::{Read,Write}` traits, but instead represent their bodies as a
`futures::Stream` of items, where each item is a `Chunk`.
- The `Client.request` method now takes a `Request`, instead of being
used as a builder, and returns a `Future` that resolves to `Response`.
- The `Handler` trait for servers is no more, and instead the Tokio
`Service` trait is used. This allows interoperability with generic
middleware.

BREAKING CHANGE: A big sweeping set of breaking changes.
2017-01-16 10:44:27 -08:00
Ahmed Charles
8b3c120684 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.
2016-08-29 13:45:38 -07:00
Sean McArthur
38aa51495a feat(uri): impl Eq and Hash for RequestUri 2016-05-16 09:51:18 -07:00
Sean McArthur
d35992d019 feat(lib): switch to non-blocking (asynchronous) IO
BREAKING CHANGE: This breaks a lot of the Client and Server APIs.
  Check the documentation for how Handlers can be used for asynchronous
  events.
2016-05-16 09:51:18 -07:00
Simon Sapin
8fa7a98968 refactor(hyper): Update to rust-url 1.0
BREAKING CHANGE: The re-exported Url type has breaking changes.
2016-04-21 16:14:08 -07:00
Manuel Woelker
80931cf4c3 feat(uri): implement fmt::Display for RequestUri (resolves #629) 2015-08-18 22:28:23 +02:00
Pyfisch
db93ca0697 style(rustfmt): run rustfmt on hyper correct overlong lines 2015-06-29 20:22:22 +02:00
Sean McArthur
7e3858c962 perf(all): replace &str.to_string() with .to_owned() 2015-05-12 23:01:58 -07:00
Sean McArthur
9ba074d150 refactor(error): remove redundant parts of error names
The old names followed the old style of including the module name and
"Error" in each variant. The new style is to refer to an error from its
owning module, and variants are now scoped to their enum, so there's no
need to include the enum name in the variant name.

BREAKING CHANGE: The terms `Http` and `Error` have been removed from the Error
  type and its variants. `HttpError` should now be accessed as `hyper::Error`,
  and variants like `HttpIoError` should be accessed as `Error::Io`.
2015-05-05 11:53:09 -07:00
Sean McArthur
0f5858f379 fix(rustup): update to rust beta 2015-04-02 12:56:20 -07:00
Florian Hartwig
c9f2c841ff fix(rustup): get rid of slice pattern, add Reflect bounds
* remove slice pattern
* add `Reflect` trait bounds where necessary
2015-03-29 19:28:32 +02:00
Sean McArthur
b87bb20f0c perf(http): changes http parsing to use httparse crate
httparse is a http1 stateless push parser. This not only speeds up
parsing right now with sync io, but will also be useful for when we get
async io, since it's push based instead of pull.

BREAKING CHANGE: Several public functions and types in the `http` module
  have been removed. They have been replaced with 2 methods that handle
  all of the http1 parsing.
2015-03-13 16:56:13 -07:00
Sean McArthur
9e3c94d764 fix(rustup): update to newest fmt trait names and slice syntax 2015-01-23 14:17:19 -08:00
Jonathan Reem
7f3a33f903 #[deriving] -> #[derive] 2015-01-03 20:31:48 +01:00
Sean McArthur
1ceb468ec3 add issue numbers to todos 2014-09-03 10:55:21 -07:00
Sean McArthur
818fac4128 add some benches with other http libs 2014-09-02 12:06:16 -07:00
Sean McArthur
c905111f8c implementation 2014-09-01 18:39:24 -07:00