2230 Commits

Author SHA1 Message Date
Nick Mathewson
45f6869c75 Make evhttp_uri non-public, and give it accessor functions. 2010-10-21 14:52:52 -04:00
Nick Mathewson
70e1b607d6 Document that two bufferevent functions only work on socket bufferevents 2010-10-21 14:05:04 -04:00
Nick Mathewson
aab49b6069 Add a bufferevent_get_base function 2010-10-21 14:04:24 -04:00
Nick Mathewson
d9ffa899fa Update the HTTP regression tests to use Libevent2 apis for non-http stuff 2010-10-21 13:04:04 -04:00
Nick Mathewson
1f507d7541 Stop using Libevent-1 headers in regress_http 2010-10-21 12:27:16 -04:00
Nick Mathewson
2a3b5872fe Merge branch 'http_small_tweaks'
Conflicts:
	http-internal.h
2010-10-21 12:23:10 -04:00
Nick Mathewson
cd00079b22 Add evhttp_connection_get_base() to get the event_base from an http connection
Based on a patch by Mark Ellzey from 27 July 2010.

Closes ticket 3052406
2010-10-21 12:19:28 -04:00
Nick Mathewson
1213d3dd8b Fix a 100%-CPU bug where an SSL connection would sometimes never stop trying to write
If an SSL connection becamse disabled or suspended before became open,
it could (under the right circumstances) wind up without ever getting
its write callback disabled.

The most correct fix is probably more subtle, and involves checking
all caseswhen a write callback is enabled or disabled.  This fix is
more blunt, and explicitly checks whether the callback should have
been disabled at the end of the callback to prevent infinite looping.

Diagnosed with help from Sebastian Hahn
2010-10-20 13:41:02 -04:00
Nick Mathewson
2075fbcff0 Add evhttp_parse_query_str to be used with evhttp_uri_parse.
The old evhttp_parse_query() doesn't work well with struct
evhttp_uri.query, since it expects to get whole URIs, rather than
just the query portion.
2010-10-19 13:15:48 -04:00
Nick Mathewson
3a33462827 Document behavior of URI parsing more thoroughly.
Also, move evhttp_uri struct into http.h, since it is part of the API.
2010-10-19 13:02:18 -04:00
Nick Mathewson
a5a76e689c Add a huge pile of tests for the new URI functions, and make them pass. 2010-10-19 12:35:50 -04:00
Nick Mathewson
ad923a11f1 Improvements to tinytest_macros.h
First, handle cases where we have %s in a tt_want or tt_assert.

Second, add tt_want_*_op that do a tt_*_op test, but do not exit the
test on failure.

We should push these upstream to tinytest some time.
2010-10-19 12:33:50 -04:00
Nick Mathewson
eaa5f1d9ed Revise evhttp_uri_parse implementation to handle more of RFC3986 2010-10-19 11:26:59 -04:00
Nick Mathewson
fadbfd4e6e Clean up error handling in uri_parse a little 2010-10-18 14:43:54 -04:00
Nick Mathewson
7d45431e15 Do not silently truncate URIs in evhttp_uri_join. Also avoid evbuffer_pullup. 2010-10-18 14:38:48 -04:00
Nick Mathewson
86212341c5 Make evhttp_uri_parse and friends conform to memory management standards 2010-10-18 14:34:20 -04:00
Pavel Plesov
86dd720a66 Introduce absolute URI parsing helpers.
See evhttp_uri_parse(), evhttp_uri_free() and evhttp_uri_join() for details.
2010-10-18 14:30:29 -04:00
Nick Mathewson
f13e449b53 Merge branch 'http_parse' 2010-10-18 14:20:06 -04:00
Nick Mathewson
49f4bf7c57 Add evhttp_request_get_command so code can tell GET from POST without peeking at the struct. 2010-10-18 13:58:02 -04:00
Nick Mathewson
e5870690fc Modernize header usage in bench_http.c 2010-10-18 13:53:31 -04:00
Nick Mathewson
9dc5f44a19 Increment version in git to 2.0.8-rc-dev 2010-10-14 22:12:32 -04:00
Nick Mathewson
ef18c994c3 Increment the version to 2.0.8-rc
NOTE: This is not the official release until I tag it.  If you see
    this commit, and you decide that Libevent 2.0.8-rc is now
    finalized, you might get something besides 2.0.8-rc.
release-2.0.8-rc
2010-10-14 18:36:07 -04:00
Nick Mathewson
15be0493f6 Changelog and readme for 2.0.8-rc 2010-10-14 18:35:11 -04:00
Nick Mathewson
4ebf9509f7 Fixes for MSVC compilation 2010-10-14 14:40:40 -04:00
Nick Mathewson
d3b096c011 Make the --enable-gcc-warnings option include signed comparison warnings 2010-10-14 13:54:15 -04:00
Nick Mathewson
e06f514d4e Fix signed/unsigned warnings on win32 2010-10-14 13:51:24 -04:00
Nick Mathewson
6be589ae68 Fix signed/unsigned warnings on opensolaris, where iov_len is signed 2010-10-14 13:48:40 -04:00
Nick Mathewson
e5c214a423 Fix -Wsigned-compare warnings in test/* 2010-10-14 13:16:41 -04:00
Nick Mathewson
f2763fa864 add limits.h to event_tagging.c so opensolaris will build 2010-10-14 13:16:00 -04:00
Nick Mathewson
5e4bafbb89 fix a signed/unsigned warning in kqueue.c 2010-10-14 13:15:32 -04:00
Nick Mathewson
02f6259fc3 New unit test for ssl bufferevents starting with connected SSLs. 2010-10-14 12:17:28 -04:00
Nick Mathewson
93bb7d8e19 Fix a case where an ssl bufferevent with CLOSE_ON_FREE didn't close its fd
This could happen when we got an SSL with a BIO already set on it.
2010-10-14 12:17:24 -04:00
Nick Mathewson
223ee40fde Avoid spurious reads from just-created open openssl bufferevents
When handshaking, we listen for reads or writes from the
transport. But when we're connected, we start out with writes enabled
and reads disabled, which means we should not have the transport read
for us.
2010-10-14 10:55:04 -04:00
Nick Mathewson
34331e456d The corrected bufferevent filter semantics let us fix our openssl tests 2010-10-14 10:55:04 -04:00
Nick Mathewson
ac27eb8276 Correct logic on disabling underlying bufferevents when disabling a filter
Previously, whenever writing was disabled on a bufferevent_filter (or
a filtering SSL bufferevent), we would stop writing on the underlying
bufferevent.  This would make for trouble, though, since if you
implemented common patterns like "stop writing once data X has been
flushed", your bufferevent filter would disable the underlying
bufferevent after the data was flushed to the underlying bufferevent,
but before actually having it written to the network.

Now, we have filters leave their underlying bufferevents enabled for
reading and writing for reading and writing immediately.  They are not
disabled, unless the user wants to disable them, which is now allowed.
To handle the case where we want to choke reading on the underlying
bufferevent because the filter no longer wants to read, we use
bufferevent_suspend_read().  This is analogous to the way that we use
bufferevent_suspend_write() to suspend writing on a filtering
bufferevent when the underlying bufferevent's output buffer has hit
its high watermark.
2010-10-14 10:55:04 -04:00
Nick Mathewson
34d64f8a34 Fix serious bugs in per-bufferevent rate-limiting code
Our old code was too zealous about deleting the refill events that
would actually make connections able to read or write again after
they had run out of bandwidth.  Under some circumstances, this could
cause a bufferevent to never actually refill one of its
rate-limiting buckets.

Also, the code treated setting a per-connection rate-limit on a
connection that already had a group-limit as if it were changing the
limit on a connection whose allocation had already run out.

This patch fixes both of those problems.
2010-10-12 13:54:07 -04:00
Nick Mathewson
819b171572 Handle rate-limiting for reading on OpenSSL bufferevents correctly.
We were looking at the number of bytes read on the wbio, not in the
rbio.  But these are usually different BIOs, and the reading is
supposed to happen on the rbio.
2010-10-12 12:59:46 -04:00
Nick Mathewson
7ad90f6a25 Merge branch '20_internal_prio' 2010-10-09 00:02:31 -04:00
Nick Mathewson
a8148cedcd New evhttp_uri(encode|decode) functions to handle + and NUL characters right
The old evhttp_decode_uri() function would act as tough it was doing
an (illegal, undefined) decode operation on a whole URL at once, and
treat + characters following a ? as different from + characters
preceding one.  But that's not useful: If you are decoding a URI
before splitting off query parameters, you are begging to fail as soon
as somebody gives you a value with an encoded & in it.

The new evhttp_uridecode() function takes an argument that says
whether to decode + signs.  Both uridecode and uriencode also now
support encoding or decoding to strings with internal 0-valued
characters.
2010-10-08 23:58:00 -04:00
Nick Mathewson
2e63a604da evhttp_encode_uri encodes all reserved characters, including !$'()*+,/:=@
Perviously, some characters not listed as "unreserved" by RFC 3986
(notably "!$'()*+,/:=@") were not encoded by evhttp_encode_uri.  This
made trouble, especially when encoding path components (where @ and /
are bad news) and parameters (where + should get encoded so it doesn't
later decode into a space).

Spotted by Bas Verhoeven.
2010-10-08 12:57:11 -04:00
Nick Mathewson
08ebd26730 Merge branch 'iovmax' 2010-10-07 21:06:25 -04:00
Nick Mathewson
120570356b Turn some booleans in evconnlistener_iocp into one-bit bitfields. 2010-10-07 18:11:38 -04:00
Christopher Davis
62b429afa8 Make iocp/listener/error work; don't accept again if lev is disabled. 2010-10-07 18:11:38 -04:00
Nick Mathewson
481ef92086 Fix allocation error for IOCP listeners. Probably harmless, since struct event is big 2010-10-07 18:11:37 -04:00
Nick Mathewson
127d4f2195 Add a LEV_OPT_THREADSAFE option for threadsafe evconnlisteners 2010-10-07 18:11:19 -04:00
Nick Mathewson
3b84489385 Tweak evhttp_parse_query hack to avoid breaking abi 2010-10-06 12:35:38 -04:00
Nick Mathewson
b1756d019d Let evhttp_parse_query return -1 on failure
We already detected certain malformed queries, but we responded by
aborting the query-parsing process half-way through without telling
the user.  Now, if query-parsing fails, no headers are returned, and
evhttp_parse_query returns -1.
2010-10-06 12:30:17 -04:00
Nick Mathewson
fdc640b02d Fix an EINVAL on evbuffer_write_iovec on OpenSolaris.
The writev() call is limited to at most IOV_MAX iovecs (or UIO_MAXIOV,
depending on whom you ask).  This isn't a problem anywhere we've
tested except on OpenSolaris, where IOV_MAX was a mere 16.

This patch makes us go from "use up to 128 iovecs when writing" to
"use up to 128 iovecs when writing, or IOV_MAX/UIO_MAXIOV, whichever
is less".  This is still wrong if you somehow find a platform that
defines IOV_MAX < UIO_MAXIOV, but I hereby claim that such a platform
is too stupid to worry about for now.

Found by Michael Herf.
2010-10-06 10:56:49 -04:00
Nick Mathewson
5b7a370636 Fix warnings on mingw with gcc 4.5 2010-10-05 14:29:48 -04:00
Nick Mathewson
145f221e8f Define symbolic constants to use in place of SHUT_RD etc 2010-10-05 13:06:32 -04:00