Commit Graph

49 Commits

Author SHA1 Message Date
cyderize
122e94c8a6 Update for latest rust
Tracks rust nightly.

7 tests fail -- still finding source
2015-01-10 18:37:10 +11:00
Marko Lalic
b6a10e5c1e Fix chunk size parsing: handle invalid chunk sizes
Currently, when the chunk size was an invalid hex number (i.e.
contained a non-HEX octet), hyper would halt its parsing at the
last valid hex digit and report this as the chunk size.

For example, the following would be the chunk sizes reported for
some strings:

    "X" => 0
    "1X" => 1
    "aY" => 10
    "a;a" => 10 (only this should be correct!)

This fix makes it so that any chunk size, which cannot be parsed
as a valid hex number, causes an IoError. Additionally, the case
where the chunk size is followed by a chunk extension is also
handled (since the ";" token is a valid delimiter between the
chunk size and, as such, along with a LWS octet, represents a
valid terminal character of the chunk size).

Regression tests for the `get_chunk_size` function and included.
2015-01-06 21:47:07 +01:00
Jonathan Reem
93fcd05b9d Miscellaneous fixes and test updates for all the other changes
- http::LINE_ENDING is now an &'static str
2015-01-06 01:15:47 +01:00
Jonathan Reem
f0fe878ec8 More Rust updates:
- Some stray deriving -> derive changes
- use::{mod} -> use::{self}
- fmt.write -> fmt.write_str

This does not catch the last case of fmt.write_str in the
Show impl of a Header Item. This will need to be changed
separately.
2015-01-05 22:50:10 +01:00
Jonathan Reem
7f3a33f903 #[deriving] -> #[derive] 2015-01-03 20:31:48 +01:00
Pyfisch
76126fc6c7 feat(headers): adds Accept
Moved utils to shared/. Added quality_value.
2015-01-03 11:06:38 -08:00
Nerijus Arlauskas
0270c82786 Update to use new array syntax. 2015-01-03 00:01:27 +02:00
Sean McArthur
451074b0a6 rust upgrade 2014-12-29 17:42:48 -08:00
Pyfisch
5fccdea90d Fixes #211 and adds one test for it. 2014-12-29 12:15:08 +01:00
Sean McArthur
79fc40cbce into_string to to_string, from_str to parse 2014-12-23 13:09:58 -08:00
Sean McArthur
691c70a380 update str::from_utf8 2014-12-23 12:55:53 -08:00
Jonathan Reem
06a9ccf978 (fix) Use the clone implementation for &str. 2014-12-20 02:39:29 -08:00
Sean McArthur
8c83a3358e feat(client): add a new Client struct with super powers
- Includes ergonomic traits like IntoUrl and IntoBody, allowing easy
usage.
- Client can have a RedirectPolicy.
- Client can have a SslVerifier.

Updated benchmarks for client. (Disabled rust-http client bench since it
hangs.)
2014-12-14 11:56:39 -08:00
Sean McArthur
0bba6e80ee rust upgrade 2014-12-12 12:24:54 -08:00
Jonathan Reem
b1ab03f7f8 (fix) Harden header parsing against memory exhaustion attacks.
Adds new limits on the lengths of header names and fields.

Fixes #187
2014-12-11 17:08:57 -08:00
Sean McArthur
36429ab50c refactor(net): NetworkConnecter no longer is for static usage
Instead, you can use an instance of a NetworkConnector with
`Request::with_connector`. This allows overloading of the NetworkStream
constructors, so that it is easy to modify how an `HttpStream` is
created, while still relying on the rest of the stream implementation.

BREAKING CHANGE
2014-12-04 17:39:38 -08:00
Sean McArthur
fec030a21e rust upgrade 2014-12-02 13:12:04 -08:00
Sean McArthur
1ed4ea5a27 Merge pull request #164 from dpc/issue-163
Fix Issue 163
2014-12-01 09:38:44 -08:00
Dawid Ciężarkiewicz
f5a7d7cfa1 Tests for "Fix handling long Reason Phrase"
Issue #163
2014-11-30 18:37:21 -08:00
Dawid Ciężarkiewicz
f3a5c0124a Fix handling long Reason Phrase
rfc2616 does not specify the maximum length of *Reason Phrase* so it's
a good practice to handle even unreasonably long input.

16 char. buffer is not enough to correctly handle even the common `304
Moved Permanently`. Increase buffer size to more realistic 32. Also, up
to 128 more characters will be read and ignored, providing even greater
versatility without increasing memory usage.

Issue #163
2014-11-30 18:37:14 -08:00
Sean McArthur
07cf414e17 fix(logging): adjust several logging messages
Closes #148
2014-11-28 18:03:37 -08:00
Peter Atashian
00a76cee03 Update to latest Rust
Signed-off-by: Peter Atashian <retep998@gmail.com>
2014-11-28 02:22:21 -05:00
Sean McArthur
4263a01f1c convert to using Cow 2014-11-27 12:13:07 -08:00
Evgeny Rozaliev
c77cd3d3da (fix) unwrap() => into_inner() 2014-11-27 16:05:19 +03:00
Sean McArthur
a60a67cd1e feat(server): properly handle requests that shouldn't have bodies 2014-11-24 21:27:59 -08:00
Sean McArthur
486080b044 feat(client): add a status_raw value 2014-11-24 19:49:12 -08:00
Till Hoeppner
8bb5f0420b Fix for ASCII_LOWER_MAP visibility and deprecation warnings 2014-11-24 21:19:46 +01:00
Austin Bonander
ff76e1c837 Fuse ChunkedReader after end
Remove debug
2014-11-24 02:27:06 -08:00
Barosl Lee
c1c0103225 Accept any token to be a valid request method
- Rename read_until_space() to read_token_until_space()
- Check if the byte is part of the token in read_token_until_space()
- Return HttpMethodError if the token is empty
- Remove the unnecessary is_valid_method() function
2014-11-23 09:17:45 +09:00
Jakob Gillich
f3e1baea9f fix(http): is_valid_method expects &-ptr 2014-11-19 22:07:11 +01:00
Kyle Dewey
d7e8b8b117 Now using use along with enums, as per https://github.com/rust-lang/rust/pull/18973. 2014-11-19 22:03:41 +01:00
Tim Kuehn
5605ade5dc impl Error and FromError for HttpError; replace instances of try_io! with try! 2014-11-10 22:59:18 -08:00
Sean McArthur
b9bfdd0537 style changes 2014-11-10 20:53:37 -08:00
Sean McArthur
d51657a831 log fixes 2014-11-10 16:28:56 -08:00
Sean McArthur
bb45ac509d some more logging 2014-11-10 16:10:52 -08:00
Sean McArthur
3b8c5cac1a fix(client): GET and HEAD shouldn't add Transfer-Encoding
Also adds an EmptyWriter, used for GET and HEAD requests,
which will return an io::ShortWrite error if the user ever tries
to write to a GET or HEAD request.

Closes #77
2014-11-09 20:56:59 -08:00
Michael Hart
8a91003e88 parse_bytes is deprecated
TBH I'm not sure if this is the most efficient method, but it matches the conversions at 138b76b83a (diff-fcdbb6413438d3b568fe96fd242d8fc9R617)
2014-11-05 11:27:16 -05:00
Sean McArthur
0ab52c9009 add bits to deal with Upgrade requests 2014-10-27 20:36:57 -07:00
Austin Bonander
ab396c2394 Fix and optimize HTTP method parsing
The old parser used a manually unrolled state machine
and was broken due to upstream rust issues with match
statements.

The new parser is a read into a stack-allocated buffer
followed by a single match on the contents of that
buffer.

This significantly improves the benchmarks for method
reads by almost 30%, in addition to working around
the upstream rust issues with reordering match blocks.
2014-10-17 01:35:11 -07:00
Sean McArthur
e6329af74e Slice was changed to AsSlice in libstd 2014-10-13 18:37:14 -07:00
Sean McArthur
2f755a5694 move rendering of headers to the Headers object 2014-10-13 14:32:48 -07:00
Stanislav Panferov
e7a2688b7e Use const instead of static 2014-10-11 11:00:10 +04:00
Sean McArthur
50a2112caf adjust RawHeaderLine to be (String, Vec<u8>) 2014-10-07 15:30:02 -07:00
Jonathan Reem
7d86296169 Migrated from .. to ... to respond to upstream changes. 2014-10-04 02:44:57 -07:00
Jonathan Reem
8d1c6a790e Parse the DELETE method and transition to push from push_char. 2014-09-26 22:57:31 -04:00
Sean McArthur
26e2a0c8f4 update to rust master 2014-09-23 21:47:27 -07:00
Sean McArthur
1c472a220a adds HttpWriters 2014-09-18 12:17:53 -07:00
Sean McArthur
42e69e1f2e ssl for the client 2014-09-15 21:12:19 -07:00
Jonathan Reem
2aabf1b8e6 Rename rfc7230 to http to more clearly indicate its purpose. 2014-09-09 17:37:01 -07:00