Commit Graph

1652 Commits

Author SHA1 Message Date
Sean McArthur
358edc0d2b fix Get and Head requests that weren't writing headers 2014-11-10 16:10:37 -08:00
Sean McArthur
3c10a8a191 feat(server): change Incoming to iterator over Connections
A connection is returned from Incoming.next(), and can be passed to a
separate thread before any parsing happens. Call conn.open() to get a
Result<(Request, Response)>.

BREAKING CHANGE
2014-11-10 13:55:11 -08:00
Sean McArthur
fcfb0505dd update to newest cookie-rs 2014-11-10 12:33:29 -08:00
Sean McArthur
33210641f7 use Vec::with_capacity(raw.len()) for Cookies 2014-11-10 12:32:11 -08:00
Sean McArthur
5c224289ec adjustments to Cookie and SetCookie 2014-11-10 12:32:11 -08:00
Stanislav Panferov
a3fc51611f Add cookie_rs as default feature and implement conditional compilation. 2014-11-10 12:31:33 -08:00
Stanislav Panferov
20f156c592 Build SetCookie from CookieJar 2014-11-10 12:31:33 -08:00
Stanislav Panferov
0a624b10e0 Add cookie-rs and use cookie::Cookie in Cookie header. 2014-11-10 12:31:33 -08:00
Stanislav Panferov
a85cc476e1 Basic Cookie and Set-Cookie (only parsing) headers implementation. 2014-11-10 12:31:33 -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
Sean McArthur
caab60e374 Merge pull request #94 from hyperium/authorization
Implemented a typed Authorization header
2014-11-08 20:55:08 -08:00
Hanno Braun
ab9c4f99b8 Make Connection usable
Connection's only field was private, making it impossible to construct a
Connection.
2014-11-08 22:51:28 +01:00
Jakob Gillich
02e72bb2be hash_map find has been renamed to get, remove returns an option 2014-11-07 17:45:48 +01:00
Sean McArthur
30534c27c9 dont convert Date to utc if already utc
Part of #98
2014-11-06 17:59:39 -08:00
Sean McArthur
3d7820d17e update using ToSocketAddr 2014-11-06 17:55:32 -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
Michael Hart
1acf567061 Update hash_map and fmt usages
Depends on https://github.com/carllerche/curl-rust/pull/24 and
https://github.com/chris-morgan/rust-http/pull/167
2014-11-04 12:34:35 -05:00
Jamie Turner
f88837f172 Add len() test with redundant header. 2014-11-03 21:08:55 -08:00
Jamie Turner
14687ad6d2 Re-add len() and clear() as inherent Headers methods. 2014-11-03 21:06:30 -08:00
Jamie Turner
bef7da153c Remove collections trait implementations.
Rust has removed them due to collections reform RFC:

RFC: https://github.com/rust-lang/rfcs/pull/235/files
Commit:
21ac985af4
2014-11-03 18:30:16 -08:00
Gilman Tolle
91a8e03e7a Implemented a typed Authorization header
An Authorization header contains a Scheme. If you have no real scheme,
you can use String as your scheme (Authorization<String>).

This includes the `Basic` scheme built-in.
2014-10-31 18:51:23 -07:00
Sean McArthur
f117ebe367 fix missing_docs lint name 2014-10-31 15:49:53 -07:00
Sean McArthur
3cd7d72b07 split NetworkStream::connect to NetworkConnector 2014-10-31 15:49:26 -07:00
Jonathan Reem
0652858dbf Update all common headers for the new Header trait split 2014-10-31 15:10:34 -07:00
Jonathan Reem
00bc001e59 Split Header into Header and HeaderFormat
Header contains all of the trait-object unsafe methods
including the name of the header and parsing. HeaderFormat
contains fmt_header, which is the only trait-object safe
method.
2014-10-31 15:09:42 -07:00
Sean McArthur
3dd61b4600 Merge pull request #59 from hyperium/upgrade
add bits to deal with Upgrade requests
2014-10-31 10:34:02 -07:00
Sean McArthur
0ab52c9009 add bits to deal with Upgrade requests 2014-10-27 20:36:57 -07:00
Sean McArthur
8cf8d5ac03 add Headers.set_raw, remove unsafe from .get_raw
Internal representation was changed from an enum back to a Struct again.
The raw representation *has* to stick around, even if parsed as a proper
typed header. The reason is that internally, hyper will access some
headers to know which parts of the http protocol to follow (such as if
the response has a length or is chunked). The raw value may still be
needed afterwards, such as for a DOM binding of
.getAllResponseHeaders().

Since the raw is kept around, the unsafety of get_raw is no longer true,
and so that is removed.

It's still more ergonomic to access the types, and safer as well, so
that is recommended when possible.
2014-10-27 17:58:21 -07:00
Sean McArthur
19045a2376 change Host header to have hostname and port 2014-10-22 18:29:49 -07:00
Hanno Braun
224cc709c3 Include port in Host header
Fixes #88.
2014-10-22 18:29:05 -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
Gilman Tolle
5615ab276e Exposed the 'from_one_raw_str' function for use in defining new header structs. 2014-10-15 23:40:40 -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
Sean McArthur
61e18141be fix client requests dropping the query string. fixes #75 2014-10-13 10:16:45 -07:00
Stanislav Panferov
e7a2688b7e Use const instead of static 2014-10-11 11:00:10 +04:00
Stanislav Panferov
d5e33ca9db (fix) abstract is now a reserved word. 2014-10-10 10:52:47 +04:00
Sean McArthur
50a2112caf adjust RawHeaderLine to be (String, Vec<u8>) 2014-10-07 15:30:02 -07:00
Stanislav Panferov
2995923505 Fix review comments 2014-10-06 22:27:08 +04:00
Stanislav Panferov
f6ac243c85 Implement the basic parsing for Accept header. 2014-10-06 19:56:32 +04:00
Stanislav Panferov
10db5ee896 Add Location header 2014-10-05 20:05:27 +04:00
Jonathan Reem
7d86296169 Migrated from .. to ... to respond to upstream changes. 2014-10-04 02:44:57 -07:00
bruse
3326e5f09c Fix typo in documentation 2014-09-28 03:23:05 +02:00
Sean McArthur
834cb09733 additional debug lines 2014-09-27 14:10:17 -07:00
Sean McArthur
5391e7f61a fix recursive overflow of read() 2014-09-27 14:09:56 -07:00
Jonathan Reem
d3a62fa0d5 Add get_mut for modifying the typed representation of Headers.
Also adds an associated test and updates code to use it instead
of cloning and setting when possible.
2014-09-27 00:17:59 -04:00
Jonathan Reem
858a09304a Remove get and rename get_ref to get
Since `get_ref` (now `get`) takes `&self` there is no need
for a special cloning method.
2014-09-27 00:17:59 -04:00
Jonathan Reem
91cc29e0aa Fixed a race condition in get_ref
If two threads attempted to `get_ref` the same Header under two
representations, then it was possible that the second thread would
overwrite the work of the first thread, causing the first thread
to do an unchecked downcast to the wrong type.

In the case where they were the same Header representation, then the
only damage would be that it would be parsed twice and would possibly
return a false negative in one thread.

The new code checks that it was not a queued lock and will not override
the work of another thread, but will accept it if the other thread parsed
the header as the same type. This also prevents duplicate parsing.
2014-09-27 00:17:58 -04:00
Jonathan Reem
e85ae48e16 Update server and client for changes in Headers mutability. 2014-09-27 00:17:58 -04:00
Jonathan Reem
90dbef1d03 Add tests for double-reads for Header to ensure safety. 2014-09-27 00:17:58 -04:00