372 Commits

Author SHA1 Message Date
Samy Al Bahra
a2c48e3be8 evhttp: Add evhttp_foreach_bound_socket.
Applies the function specified in the first argument to all
evhttp_bound_sockets associated with a struct evhttp. The user
must not attempt to free or remove any connections, sockets or
listeners in the callback function.
2011-10-25 22:17:24 -04:00
Nick Mathewson
3c824bd334 Update copyright dates to 2011. 2011-10-24 13:18:09 -04:00
Nick Mathewson
4d63758364 Remove calls to deprecated bufferevent functions from evhttp.c 2011-09-12 10:57:37 -04:00
Nick Mathewson
8d3a8500f4 Add evhttp callback for bufferevent creation; this lets evhttp support SSL.
Based on a patch uploaded anonymously to sourceforge; cleaned up
by Graham Leggett to work with current libevents.
2011-09-12 10:48:35 -04:00
Nick Mathewson
0fcc536bcd Add missing break to evhttp_parse_request_line 2011-08-01 10:30:32 -04:00
Nick Mathewson
b07940ced7 Merge remote-tracking branch 'origin/patches-2.0' 2011-07-05 14:58:35 -04:00
Nick Mathewson
4df9b43305 Merge remote-tracking branch 'origin/patches-2.0' 2011-06-08 17:38:17 -04:00
Nick Mathewson
3203f88c5f Use the correct printf args when formatting size_t
Based on a patch from Mansour Moufid
2011-06-08 17:37:45 -04:00
Mansour Moufid
446cc7a0a1 Check if the evhttp_new_object' function in http.c' returns NULL. 2011-06-08 16:46:21 -04:00
Nick Mathewson
356720a23b Merge remote-tracking branch 'origin/patches-2.0' 2011-05-27 15:09:54 -04:00
Nick Mathewson
203ba2742f Fix a couple of signed/unsigned warnings in http.c 2011-05-27 15:08:25 -04:00
Nick Mathewson
29e5f7ea1b Merge remote-tracking branch 'origin/patches-2.0' 2011-05-26 17:45:54 -04:00
Nick Mathewson
dbb3c65288 Fix compilation. 2011-05-26 17:43:17 -04:00
Mark Ellzey
1814ae9677 updated EV_S(s)IZE definitions 2011-05-26 17:33:18 -04:00
Mark Ellzey
84560fc4dc Added overflow checks in evhttp_read_body and evhttp_get_body 2011-05-26 17:33:18 -04:00
Mark Ellzey
a27927229f Added several checks for under/overflow conditions in evhttp_handle_chunked_read 2011-05-26 17:33:18 -04:00
Nick Mathewson
9f560bfa11 Use "_WIN32", not WIN32: it's standard and we don't need to fake it
This patch was automatically generated with perl.

Based on a patch by Peter Rosin.
2011-05-25 20:03:15 -04:00
Nick Mathewson
173509d9b6 Merge remote-tracking branch 'origin/patches-2.0' 2011-05-23 18:25:05 -04:00
Mansour Moufid
06c51cdf93 Prevent size_t overflow in evhttp_htmlescape.
Modified the `html_replace' function so that it returns the length of
the replacement string instead of the string itself. This is used to
easily check for overflows of the `new_size' variable in the first for
loop of the `evhttp_htmlescape' function, and thus potential out of
bounds writes in the second for loop (if an overflow occurs in
new_size, then new_size < old_size). Also check that new_size + 1
doesn't overflow in mm_malloc(new_size + 1).

Removed the `scratch_space' variable from the `evhttp_htmlescape'
function since it wasn't actually used; also removed the `buf'
variable from the `evhttp_htmlescape' function since it was only used
by `scratch_space'.
2011-05-23 18:01:24 -04:00
Nick Mathewson
63d37bdd3e Merge remote-tracking branch 'origin/patches-2.0' 2011-05-20 23:24:43 -04:00
Kevin Ko
0848814ac4 Fix failing assertion introducd in commit 0d6622e
Patch in question:
 - Fix the case when failed evhttp_make_request() leaved request in the queue.
 - http://levent.git.sourceforge.net/git/gitweb.cgi?p=levent/libevent;a=commit;h=0d6622e

The above patch introduces a failing assertion in
evhttp_connection_fail().  This happens because the patch defers the
assignment of the outstanding request to the evcon->requests list,
while evhttp_connection_fail() assumes that the request lies in the
list.

One scenario in which this can happen is when the request list is
empty and a connection is made to an unreachable host.  The assertion
will then fail after bufferevent_socket_connect() errors out (with
ENETUNREACH in my case).
2011-05-20 23:23:44 -04:00
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