301 Commits

Author SHA1 Message Date
Nick Mathewson
af5f186038 Merge remote-tracking branch 'ellzey/feature/evhttp_parse_speedup' 2011-05-20 23:08:25 -04:00
Mark Ellzey
aee1a97da4 Performance tweak to evhttp_parse_request_line.
Method parsing has been tweaked out to use a lookup table instead of multiple
branching. In our testing it has increased performance by a fair bit.
2011-05-06 08:48:54 -04:00
Nick Mathewson
614b9bd1f3 Merge remote-tracking branch 'origin/patches-2.0' 2011-04-26 23:48:31 -04:00
Nick Mathewson
e49e64e774 Fix clang warning when resetting connection
This was a regression on 2.0.10-stable: clang was warning about
values that were unused (because event_debug wasn't using them unless
USE_DEBUG was defined).  Found by Sebastian Hahn.
2011-04-26 23:42:01 -04:00
Nick Mathewson
614a1712b7 Merge remote-tracking branch 'origin/patches-2.0'
Conflicts:
	evthread.c
2011-04-22 23:46:25 -04:00
Sebastian Hahn
12311ff46e Add a forgotten NULL check to evhttp_parse_headers
Issue detected by the clang static analyzer
2011-04-23 02:04:58 +02:00
Nick Mathewson
ddcca1760f Merge remote-tracking branch 'origin/patches-2.0' 2011-04-04 15:09:47 -04:00
Tomash Brechko
0d6622e26a Fix the case when failed evhttp_make_request() leaved request in the queue. 2011-04-04 14:45:53 -04:00
Tomash Brechko
218cf19743 Fix subtle recursion in evhttp_connection_cb_cleanup(). 2011-04-04 14:44:34 -04:00
Tomash Brechko
272823f8b0 Reset outgoing connection when read data in idle state.
Imagine server side is buggy and miscalculates Content-Length: in the
reply.  Data arriving in idle state shouldn't make us crash, instead we
can just reset the connection.
2011-04-04 14:41:45 -04:00
Nick Mathewson
c53895944d Merge remote branch 'origin/patches-2.0' 2011-03-07 21:59:47 -05:00
Nick Mathewson
c8baac9023 Followup for Tomash Brechko's http patch
This patch makes bufferevent_disable_hard() non-public, and
adds a comment about what it's for and why it's used.
2011-03-07 21:58:16 -05:00
Tomash Brechko
5dc566284d Workaround libevent bug
https://sourceforge.net/tracker/index.php?func=detail&aid=3078187&group_id=50884&atid=461324

The problem is that bufferevent_disable() doesn't disable EV_WRITE
when 'connecting' flag is set.  However from evhttp_connection_reset()
we want to disable EV_WRITE for sure (we are closing the socket next).
So we add bufferevent_disable_hard(), which acts like
bufferevent_disable(), but resets 'connecting' flag before the call to
the actual handler.

TODO: bufferevent_disable_hard() shouldn't be public, remove it from
event2/bufferevent.h.
2011-03-07 21:41:45 -05:00
Nick Mathewson
e2e3c32239 Merge remote branch 'origin/patches-2.0' 2011-02-22 18:55:05 -05:00
Nick Mathewson
5dc200b7c8 Merge branch '20_uri_nonconformant' into patches-2.0 2011-02-22 18:53:55 -05:00
Constantine Verutin
6350e6c4c5 Add new evhttp_{connection_}set_timeout_tv() functions to set finger-grained http timeouts 2011-02-22 17:52:50 -05:00
Nick Mathewson
a11c30b5fe Merge remote branch 'origin/patches-2.0'
This branch is the big one that merges all the ntp folks' changes

Conflicts:
	configure.in
2011-02-22 17:41:27 -05:00
Harlan Stenn
10c834c4df Include arpa/inet.h as needed on HPUX 2011-02-22 00:24:36 -05:00
Nick Mathewson
8f5cca47dd Merge remote branch 'origin/patches-2.0' 2011-02-21 23:27:23 -05:00
Nick Mathewson
63a715e125 Correctly detect and stop non-chunked http requests when the body is too long
Based on analysis and code from Bas Verhoeven and from
Constantine Verutin.
2011-02-21 23:25:13 -05:00
Nick Mathewson
95060b54fe Make URI parser able to tolerate nonconformant URIs.
If the EVHTTP_URI_NONCONFORMANT flag is passed in (which it is when
parsing URIs we get over the wire), then we relax our checks a lot.
Specifically, we do nothing to check for correct characters in the
path, query, and fragment parts of such a URI.

We could do much more here: we could relax our hostname requirements,
deal with spaces differently/better, trap some errors but not others,
etc.  But this should solve the worst user-agent compatibility issues
for now; the other issues can wait for a later release.
2011-02-13 00:41:22 -05:00
Nick Mathewson
8b0afe96eb Merge remote branch 'origin/patches-2.0' 2011-01-12 21:41:58 -05:00
Jardel Weyrich
3f8d22a123 Use event_err() only if the failure is truly unrecoverable. 2011-01-07 13:03:32 -05:00
Jardel Weyrich
666b096691 Detect and handle more allocation failures. 2011-01-07 13:03:31 -05:00
Kevin Bowling
0915ca0aa6 Include evconfig-private.h in internal files for great good. 2011-01-02 08:43:45 -07:00
Nick Mathewson
bb0d2b4e85 Consistentize tabs 2010-12-09 11:47:54 -05:00
Nick Mathewson
22f4af6580 Remove end-of-line whitespace 2010-12-09 11:43:12 -05:00
Nick Mathewson
7011f9ec1f Fix a signed/unsigned comparison in the last commit 2010-12-07 11:45:14 -05:00
Constantine Verutin
d23839fc6e Reject overlong http requests early when Expect:100-continue is set 2010-12-07 11:43:52 -05:00
Nick Mathewson
04861d5e62 Correctly detect timeouts during http connects 2010-11-30 00:05:54 -05:00
Nick Mathewson
0faaa39592 Try to fix an assertion failure related to close detection
f700566c removed a line from evhttp_connection_stop_detectclose that
cleared the EVHTTP_CON_CLOSEDETECT flag.  I think this was an
accident, and suspect that it may be the cause of bug 3069555.
2010-11-29 22:44:18 -05:00
Christopher Davis
fa9305f8f5 Preliminary support for Continue expectation in evhttp. 2010-11-29 18:25:04 -08:00
Nick Mathewson
a12839b083 Merge remote branch 'chrisd/http_fixes2' 2010-11-29 14:25:33 -05:00
Christopher Davis
aab8c38b76 Add evhttp server alias interface, correct flagging of proxy requests.
evhttp needs to be mindful of all hostnames and addresses that clients
use to contact the main server and vhosts to know the difference between
proxy requests and non-proxy requests.
2010-11-26 03:58:28 -08:00
Nick Mathewson
ec5c5aec6d Handle evhttp PUT/POST requests with an empty body
When we call evhttp_get_bodylen() [when transfer-encoding isn't set],
having req->ntoread == -1 means that we have no content-length.  But a
request with no content-length has no body!  We were treating the
absent content-length as meaning "read till closed", which only holds
for replies, not requests.

This patch also allows PATCH requests to have a body.
2010-11-23 20:31:28 -05:00
Nick Mathewson
8faf223ac5 Fix a memory leak in evhttp_uri_free. 2010-11-17 00:09:10 -05:00
Nick Mathewson
5c8a59e886 Merge remote branches 'github/20_evdns_cancel_segfault_v2', 'github/20_http_close_detect', 'github/20_http_versions', 'github/20_more_http_methods', 'github/20_shutdown_iocp_listener' and 'github/20_win64_fixes' 2010-11-09 10:19:05 -05:00
Nick Mathewson
a38140be18 Refactor http version parsing into a single function
Based on a suggestion by Chris Davis to make
evhttp_parse_response_line tolerate odd versions too.
2010-11-09 10:14:32 -05:00
Nick Mathewson
05124879d3 Never call evhttp_readcb while writing. 2010-11-04 14:05:08 -04:00
Felix Nawothnig
c76640b5c2 Don't disable reading from the HTTP connection after sending the request to be notified of connection-close in time 2010-11-04 14:01:26 -04:00
Nick Mathewson
536311a46b evhttp: Return 501 when we get an unrecognized method, not 400. 2010-11-04 12:39:41 -04:00
Nick Mathewson
f5b391e22e Tweak interface for allowed methods 2010-11-04 11:53:36 -04:00
Felix Nawothnig
75a73414a4 Define enumerators for all HTTP methods, including PATCH from RFC5789
This patch defines enumerators for all HTTP methods that exist
(including PATCH introduced in RFC 5789).

It also makes them bit-masky (that's not a word, is it?), breaking
binary- but not source-code compatibility.

evhttp now stores a bitmask specifying for which methods requests to
dispatch and which ones to reject with "405 Method Not Allowed".

By default that's the ones we currently have (GET, POST, HEAD, PUT,
DELETE), thereby keeping functional compatibility (besides the minor
change that one of the other methods will now cause 405 instead of
400. But I believe that could even be considered a bug-fix).

evhttp is extended by evhttp_set_allowed_methods() with which the
user can change that bitmask.

no regressions here and my test-app still works. Haven't yet
actually tested any of the new methods.

What's obviously missing here is the special logic for the methods:

OPTIONS: We should be fine here - I believe our current dispatch
logic should work fine. Some convenience functions would be fine
though.

TRACE: I'm pretty certain we should never dispatch this to the
callbacks and simply implement the necessary functionality built-in.

CONNECT: Pretty straight-forward to implement (and considering the
framework in which we implement it very efficient too). Should
probably go built-in.

PATCH: Except for checking the RFC against our pre-dispatch logic
(there just might be some "MUST not have Some-Header" lurking
somewhere) there is nothing to be done here, this is completely up
to the user. Nothing to do.
2010-11-04 11:53:36 -04:00
Nick Mathewson
78762383b7 Merge branch 'http_nolegacy_v2' 2010-11-03 15:18:34 -04:00
Nick Mathewson
22e0a9b2e8 Add evhttp_response_code to remove one more reason to include http_struct.h 2010-11-03 15:12:08 -04:00
Nick Mathewson
647e094ca2 Replace exact-version checks for HTTP/1.1 with >= or < checks 2010-11-02 15:19:12 -04:00
Joachim Bauch
aa5f55face reset "chunked" flag when sending non-chunked reply 2010-11-02 13:50:57 -04:00
Nick Mathewson
74a91e5aaf fix signed/unsigned warnings in http.c 2010-11-01 14:16:39 -04:00
Nick Mathewson
545a61145c Fix even more win64 warnings: buffer, event_tagging, http, evdns, evrpc 2010-11-01 14:13:33 -04:00
Nick Mathewson
84a7053e41 Merge remote branch 'github/20_http_read_after_write' 2010-10-26 21:33:22 -04:00