http.c


Log

Author Commit Date CI Message
Nick Mathewson a220a081 2012-02-15T21:07:44 Merge remote-tracking branch 'github/21_fast_syscalls'
Nick Mathewson 539466e5 2012-02-10T17:33:50 Merge remote-tracking branch 'origin/patches-2.0' Conflicts: Makefile.am WIN32-Code/event2/event-config.h configure.in
Nick Mathewson e49e2891 2012-02-10T17:29:53 Update copyright notices to 2012
Nick Mathewson af6c9d8e 2012-02-10T16:32:32 Save syscalls when constructing listener sockets for evhttp
Nick Mathewson 350a3c40 2012-01-24T14:34:04 New evhttp function to adjust initial retry timeout
Nick Mathewson 677f23cc 2012-01-20T11:40:39 Merge remote-tracking branch 'origin/patches-2.0'
Catalin Patulea 790f6b3b 2012-01-10T18:33:58 Force strict validation of HTTP version in response. This sometimes accepted invalid versions like 'ICY' (n = 0, major = undefined, sometimes > 1).
Arno Bakker da70fa70 2011-12-14T16:17:19 Backport evhttp_connection_get_bufferevent to Libevent 2.0 Backport by Arno Bakker; original implementation in 8d3a8500f4
Nick Mathewson 0cb70e33 2011-10-26T10:17:21 Merge remote-tracking branch 'origin/patches-2.0'
Samy Al Bahra a2c48e3b 2011-10-24T01:31:55 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.
Nick Mathewson 3c824bd3 2011-10-24T13:18:09 Update copyright dates to 2011.
Nick Mathewson 4d637583 2011-09-12T10:57:37 Remove calls to deprecated bufferevent functions from evhttp.c
Nick Mathewson 8d3a8500 2011-09-12T10:46:17 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.
Nick Mathewson 0fcc536b 2011-08-01T10:30:32 Add missing break to evhttp_parse_request_line
Nick Mathewson b07940ce 2011-07-05T14:58:35 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson 4df9b433 2011-06-08T17:38:17 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson 3203f88c 2011-06-08T17:18:03 Use the correct printf args when formatting size_t Based on a patch from Mansour Moufid
Mansour Moufid 446cc7a0 2011-05-27T18:40:31 Check if the `evhttp_new_object' function in `http.c' returns NULL.
Nick Mathewson 356720a2 2011-05-27T15:09:54 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson 203ba274 2011-05-27T15:08:25 Fix a couple of signed/unsigned warnings in http.c
Nick Mathewson 29e5f7ea 2011-05-26T17:45:54 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson dbb3c652 2011-05-26T17:43:17 Fix compilation.
Mark Ellzey 1814ae96 2011-05-25T18:52:07 updated EV_S(s)IZE definitions
Mark Ellzey 84560fc4 2011-05-25T14:31:09 Added overflow checks in evhttp_read_body and evhttp_get_body
Mark Ellzey a2792722 2011-05-25T12:58:59 Added several checks for under/overflow conditions in evhttp_handle_chunked_read
Nick Mathewson 9f560bfa 2011-05-25T19:50:56 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.
Nick Mathewson 173509d9 2011-05-23T18:25:05 Merge remote-tracking branch 'origin/patches-2.0'
Mansour Moufid 06c51cdf 2011-05-23T18:01:24 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'.
Nick Mathewson 63d37bdd 2011-05-20T23:24:43 Merge remote-tracking branch 'origin/patches-2.0'
Kevin Ko 0848814a 2011-05-20T23:23:44 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).
Nick Mathewson af5f1860 2011-05-20T23:08:25 Merge remote-tracking branch 'ellzey/feature/evhttp_parse_speedup'
Mark Ellzey aee1a97d 2011-05-06T08:48:54 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.
Nick Mathewson 614b9bd1 2011-04-26T23:48:31 Merge remote-tracking branch 'origin/patches-2.0'
Nick Mathewson e49e64e7 2011-04-26T23:42:01 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.
Nick Mathewson 614a1712 2011-04-22T23:46:25 Merge remote-tracking branch 'origin/patches-2.0' Conflicts: evthread.c
Sebastian Hahn 12311ff4 2011-03-14T04:13:55 Add a forgotten NULL check to evhttp_parse_headers Issue detected by the clang static analyzer
Nick Mathewson ddcca176 2011-04-04T15:09:47 Merge remote-tracking branch 'origin/patches-2.0'
Tomash Brechko 0d6622e2 2011-03-31T19:11:10 Fix the case when failed evhttp_make_request() leaved request in the queue.
Tomash Brechko 218cf197 2011-03-24T15:52:34 Fix subtle recursion in evhttp_connection_cb_cleanup().
Tomash Brechko 272823f8 2011-03-23T12:05:33 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.
Nick Mathewson c5389594 2011-03-07T21:59:47 Merge remote branch 'origin/patches-2.0'
Nick Mathewson c8baac90 2011-03-07T21:55:47 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.
Tomash Brechko 5dc56628 2011-02-24T12:30:40 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.
Nick Mathewson e2e3c322 2011-02-22T18:55:05 Merge remote branch 'origin/patches-2.0'
Nick Mathewson 5dc200b7 2011-02-22T18:53:55 Merge branch '20_uri_nonconformant' into patches-2.0
Constantine Verutin 6350e6c4 2011-02-22T17:52:50 Add new evhttp_{connection_}set_timeout_tv() functions to set finger-grained http timeouts
Nick Mathewson a11c30b5 2011-02-22T17:41:27 Merge remote branch 'origin/patches-2.0' This branch is the big one that merges all the ntp folks' changes Conflicts: configure.in
Harlan Stenn 10c834c4 2011-02-13T01:22:25 Include arpa/inet.h as needed on HPUX
Nick Mathewson 8f5cca47 2011-02-21T23:27:23 Merge remote branch 'origin/patches-2.0'
Nick Mathewson 63a715e1 2011-02-21T23:25:13 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.
Nick Mathewson 95060b54 2011-02-13T00:41:22 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.
Nick Mathewson 8b0afe96 2011-01-12T21:41:58 Merge remote branch 'origin/patches-2.0'
Jardel Weyrich 3f8d22a1 2010-12-18T02:40:22 Use event_err() only if the failure is truly unrecoverable.
Jardel Weyrich 666b0966 2010-12-18T01:07:27 Detect and handle more allocation failures.
Kevin Bowling 0915ca0a 2011-01-02T08:43:45 Include evconfig-private.h in internal files for great good.
Nick Mathewson bb0d2b4e 2010-12-09T11:47:54 Consistentize tabs
Nick Mathewson 22f4af65 2010-12-09T11:43:12 Remove end-of-line whitespace
Nick Mathewson 7011f9ec 2010-12-07T11:45:14 Fix a signed/unsigned comparison in the last commit
Constantine Verutin d23839fc 2010-12-07T11:43:52 Reject overlong http requests early when Expect:100-continue is set
Nick Mathewson 04861d5e 2010-11-30T00:05:54 Correctly detect timeouts during http connects
Nick Mathewson 0faaa395 2010-11-29T22:44:18 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.
Christopher Davis fa9305f8 2010-11-29T18:25:04 Preliminary support for Continue expectation in evhttp.
Nick Mathewson a12839b0 2010-11-29T14:25:33 Merge remote branch 'chrisd/http_fixes2'
Christopher Davis aab8c38b 2010-11-05T11:17:07 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.
Nick Mathewson ec5c5aec 2010-11-23T20:31:28 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.
Nick Mathewson 8faf223a 2010-11-17T00:09:10 Fix a memory leak in evhttp_uri_free.
Nick Mathewson 5c8a59e8 2010-11-09T10:19:05 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'
Nick Mathewson a38140be 2010-11-09T10:14:32 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.
Nick Mathewson 05124879 2010-11-04T14:05:08 Never call evhttp_readcb while writing.
Felix Nawothnig c76640b5 2010-06-01T04:45:55 Don't disable reading from the HTTP connection after sending the request to be notified of connection-close in time
Nick Mathewson 536311a4 2010-11-04T12:39:41 evhttp: Return 501 when we get an unrecognized method, not 400.
Nick Mathewson f5b391e2 2010-11-04T11:53:34 Tweak interface for allowed methods
Felix Nawothnig 75a73414 2010-11-04T11:25:35 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.
Nick Mathewson 78762383 2010-11-03T15:18:34 Merge branch 'http_nolegacy_v2'
Nick Mathewson 22e0a9b2 2010-11-03T15:12:08 Add evhttp_response_code to remove one more reason to include http_struct.h
Nick Mathewson 647e094c 2010-11-02T15:19:12 Replace exact-version checks for HTTP/1.1 with >= or < checks
Joachim Bauch aa5f55fa 2010-11-02T13:50:57 reset "chunked" flag when sending non-chunked reply
Nick Mathewson 74a91e5a 2010-11-01T14:16:39 fix signed/unsigned warnings in http.c
Nick Mathewson 545a6114 2010-11-01T13:59:04 Fix even more win64 warnings: buffer, event_tagging, http, evdns, evrpc
Nick Mathewson 84a7053e 2010-10-26T21:33:22 Merge remote branch 'github/20_http_read_after_write'
Nick Mathewson a4063c06 2010-10-26T10:38:30 Note that 2.0.9 will break the ABI, and make changes we were postponing. We had to turn a couple of 32-bit size arguments into 64-bit arguments or size_t arguments (since otherwise we would have had to do it post 2.0.x-stable, and that would be worse).
Nick Mathewson 74c0e862 2010-10-25T21:53:15 Avoid missed-request bug when entire http request arrives before data is flushed The trigger for starting to read the first line of a request used to be, "When data has arrived and we're looking for the first line." But that's not good enough: if the entire next request gets read into our bufev->inbuf while we're still processing the current request, we'll never see any more data arrive, and so will never process it. So the fix is to make sure that whenever we hit evhttp_send_done, we call evhttp_read_cb. We can't call it directly, though, since evhttp_send_done is reachable from the user API, and evhttp_read_cb can invoke user functions, and we don't want to force everyone to have reentrant callbacks. So, we use a deferred_cb. Found by Ivan Andropov. This is bug 3008344.
Nick Mathewson 8e342e56 2010-10-25T16:09:11 Correctly count req->body_size on http usage without Content-Length There was a dumb bug where we would look at the length of the input buffer immediately _after_ we drained it.
Nick Mathewson 58a1cc6b 2010-10-25T16:00:47 Fix a bug where we would read too much data in HTTP bodies or requests. We were using evbuffer_add_buffer, which moved the entire buffer contents. But if we had a valid content_length, we only wanted to move up to the amount of data remaining in ntoread. Our bug would make us put our ntoread in the negative, which would in turn make us read all data until the connection closed. Found by Denis Bilenko. Should fix bug 2963172.
Nick Mathewson 525da3e1 2010-10-25T15:49:42 Fix Content-Length when trying send more than 100GB of data (!) on an evhttp.
Nick Mathewson 006efa7d 2010-10-25T11:50:51 Functions to actually use evhttp_bound_socket with/as evconnlistener.
Nick Mathewson bf11e7dd 2010-10-21T15:33:13 Merge branch 'http_uri_parse'
Nick Mathewson 45f6869c 2010-10-21T14:41:12 Make evhttp_uri non-public, and give it accessor functions.
Nick Mathewson 2a3b5872 2010-10-21T12:23:10 Merge branch 'http_small_tweaks' Conflicts: http-internal.h
Nick Mathewson cd00079b 2010-10-21T12:19:28 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
Nick Mathewson 2075fbcf 2010-10-19T13:15:48 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.
Nick Mathewson a5a76e68 2010-10-19T12:35:50 Add a huge pile of tests for the new URI functions, and make them pass.
Nick Mathewson eaa5f1d9 2010-10-19T11:26:59 Revise evhttp_uri_parse implementation to handle more of RFC3986
Nick Mathewson fadbfd4e 2010-10-18T14:43:54 Clean up error handling in uri_parse a little
Nick Mathewson 7d45431e 2010-10-18T14:38:48 Do not silently truncate URIs in evhttp_uri_join. Also avoid evbuffer_pullup.
Nick Mathewson 86212341 2010-10-18T14:34:20 Make evhttp_uri_parse and friends conform to memory management standards
Pavel Plesov 86dd720a 2010-08-08T16:46:39 Introduce absolute URI parsing helpers. See evhttp_uri_parse(), evhttp_uri_free() and evhttp_uri_join() for details.
Nick Mathewson 49f4bf7c 2010-10-18T13:58:02 Add evhttp_request_get_command so code can tell GET from POST without peeking at the struct.
Nick Mathewson a8148ced 2010-10-08T13:05:13 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.
Nick Mathewson 2e63a604 2010-10-08T12:57:11 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.