219 Commits

Author SHA1 Message Date
Frank Denis
953e2290fc Refuse null keys in evhttp_parse_query()
evhttp_parse_query() currently accepts empty keys, that don't make any
sense.

-Frank

[From sourceforge patch 2995183]
-Nick
2010-05-03 11:39:40 -04:00
Sebastian Hahn
bd1ed5f3c5 Fix a compile warning introduced in 739e688 2010-05-02 12:52:06 +02:00
Pierre Phaneuf
739e688275 Allow empty reason line in HTTP status 2010-04-28 21:33:13 -07:00
Niels Provos
9d8edf2ff5 do not leak the request object on persistent connections 2010-04-23 18:59:22 -07:00
Sebastian Sjöberg
899c1dcc98 Replace EVUTIL_CLOSESOCKET macro with a function
The EVUTIL_CLOSESOCKET() macro required you to include unistd.h in your
source for POSIX.  We might as well turn it into a function: an extra
function call is going to be cheap in comparison with the system call.

We retain the EVUTIL_CLOSESOCKET() macro as an alias for the new
evutil_closesocket() function.

(commit message from email by Nick and Sebastian)
2010-04-14 15:42:57 -04:00
Brodie Thiesfield
13e4f3bd89 Avoid errors in http.c when building with VC 2003 .NET 2010-03-08 13:46:48 -05:00
Nick Mathewson
c7cf6f0049 Replace users of "int fd" with "evutil_socket_t fd" in portable code
Remeber, win32 has a socket type that's actually a handle, so if
there's a chance that code is run on win32, we can't use "int" as the
socket type.

This isn't a blind search-and-replace: sometimes an fd is really in
fact for a file, and not a socket at all.
2010-03-05 12:47:46 -05:00
Nick Mathewson
17efc1cdfa Update all our copyright notices to say "2010" 2010-03-04 01:38:48 -05:00
Nick Mathewson
e5cf98795e Clean up formatting: remove trailing spaces 2010-02-18 17:46:56 -05:00
Nick Mathewson
e5bbd40ad7 Clean up formatting: use tabs, not 8-spaces, to indent. 2010-02-18 17:44:09 -05:00
Nick Mathewson
8fdf09c09d Clean up formatting: Disallow space-before-tab. 2010-02-18 17:08:50 -05:00
Nick Mathewson
cfe7a9ff4c Merge remote branch 'niels/http_chunk' 2010-02-04 10:15:39 -05:00
Niels Provos
397818011b make evhttp_send() safe against terminated connections, too 2010-02-03 16:54:18 -08:00
Nick Mathewson
e2d15d81c3 Merge remote branch 'niels/http_chunk' 2010-02-03 17:52:55 -05:00
Niels Provos
93d7369106 do not fail while sending on http connections the client closed.
when sending chunked requests via multiple calls to evhttp_send_reply_chunk,
the client may close the connection before the server is done sending. this
used to cause a crash.

we introduce a new function evhttp_request_get_connection() that allows the
server to determine if the request is still associated with a connection.
If it's not, evhttp_request_free() needs to be called explicitly or the user
can call evhttp_send_reply_end() which just frees the request, too.
2010-02-03 14:34:56 -08:00
Nick Mathewson
8f65467848 Merge remote branch 'github/http_listener'
Conflicts:
	http.c
2010-02-03 16:25:34 -05:00
Nick Mathewson
a19b4a05e6 Call event_debug_unassign on internal events
I don't expect that many users will be so religious about calling
unassign, but we need to be so that it's at least possible to use
debug mode without eating memory.
2010-01-25 13:53:17 -05:00
Nick Mathewson
5c7a7bca4c Fix windows and msvc build 2010-01-23 20:07:05 -05:00
Nick Mathewson
ff3f6cd42b Check more internal event_add() calls for failure
Most of these should be unable to fail, since adding a timeout
generally always works.  Still, it's better not to try to be "too
smart for our own good here."

There are some remaining event_add() calls that I didn't add checks
for; I've marked those with "XXXX" comments.
2010-01-22 16:14:49 -05:00
Niels Provos
5032e52680 do not use a function to assign the evdns base; instead assign it via evhttp_connection_base_new() which is a new function introduced in 2.0 2010-01-14 15:42:07 -08:00
Nick Mathewson
ec34533a9c Make http use evconnlistener.
Now that we have a generic listen-on-a-socket mechanism, there's no
longer any reason to have a separate listen-on-a-socket implementation
in http.c.

This also lets us use IOCP and AcceptEx() when they're enabled.

Possibly, we should have a new mechanism to add a socket given only a
listener.
2010-01-14 15:22:15 -05:00
Nick Mathewson
c698b77d19 Allow http connections to use evdns for hostname looksups.
This was as simple as using bufferevent_connect_hostname instead of
calling connect() ourself, which already knows how to use an
evdns_base if it gets one.

Untangling the bind code might be a little trickier.
2010-01-14 15:18:25 -05:00
Jardel Weyrich
d0939d2b97 Introduced evutil_make_socket_closeonexec() to preserve fd flags for F_SETFD.
Use this to eliminate the various macros that called F_SETFD throughout
the code.
2009-12-29 15:12:56 -05:00
Niels Provos
f169153956 Remove most calls to event_err() in http and deal with memory errors instead
svn:r1555
2009-11-19 23:08:50 +00:00
Niels Provos
b8f222e055 On FreeBSD and other OSes, connect can return ECONREFUSED immediately; instead of failing the function call, pretend with faileld in the callback.
svn:r1553
2009-11-19 21:14:31 +00:00
Nick Mathewson
86f5742015 Add two implementations of getaddrinfo: one blocking and one nonblocking.
The entry points are evutil_getaddrinfo and evdns_getaddrinfo respectively.
There are fairly extensive unit tests.

I believe this code conforms to RFC3493 pretty closely, but there are
probably more issues.  It should get tested on more platforms.

This code means we can dump the well-intentioned but weirdly-implemented
bufferevent_evdns and evutil_resolve code.

svn:r1537
2009-11-16 22:25:46 +00:00
Nick Mathewson
c79a45e009 Fix a couple of event_debug calls.
svn:r1527
2009-11-14 21:54:30 +00:00
Nick Mathewson
37e23f806b Patch from Ryan Phillips: accept ipv6 addresses returned by getaddrinfo in http.c
svn:r1522
2009-11-09 18:50:20 +00:00
Nick Mathewson
784b8773a4 We do not work any more without an event-config.h; stop pretending that it is meaningful to check for HAVE_CONFIG_H
svn:r1516
2009-11-06 21:46:57 +00:00
Nick Mathewson
ac633aebdf Fix some build warnings on MSVC, mostly related to signed/unsigned comparisons.
svn:r1510
2009-11-05 21:22:23 +00:00
Nick Mathewson
34f28e08b3 Fix a few types to use compatible versions
svn:r1501
2009-11-05 15:57:22 +00:00
Nick Mathewson
47bad8abb7 Implement size limits on HTTP header length and body length.
Patch from Constantine Verutin, simplified a little.

svn:r1500
2009-11-04 20:17:32 +00:00
Nick Mathewson
0b9eb1bffb Add a bufferevent function to resolve a name then connect to it.
This function, bufferevent_socket_connect_hostname() can either use
evdns to do the resolve, or use a new function (evutil_resolve) that
uses getaddrinfo or gethostbyname, like http.c does now.

This function is meant to eventually replace the hostname resolution mess in
http.c.

svn:r1496
2009-11-03 20:40:48 +00:00
Nick Mathewson
2e36dbe1a6 Use EVUTIL_ASSERT() consistently instead of assert.
svn:r1464
2009-10-26 20:00:43 +00:00
Nick Mathewson
e3fd294a6d Spelling fixes in comments and strings.
svn:r1445
2009-10-16 13:19:57 +00:00
Nick Mathewson
2c1b0e4428 Fix build warnings and add changelog entry for evhttp patches.
svn:r1424
2009-08-16 19:22:15 +00:00
Nick Mathewson
c8b0fe4ad7 Define evhttp_del_accept_socket
[Patch from David Reiss]

svn:r1423
2009-08-16 19:22:10 +00:00
Nick Mathewson
6c53334c65 Define evhttp_{bind,accept}_socket_with_handle
[Patch from David Reiss]

svn:r1422
2009-08-16 19:22:04 +00:00
Nick Mathewson
4bcd5646d8 Make evhttp_bound_socket visible, and provide an accessor to its fd
Declare the previously private struct evhttp_bound_socket in
event2/http.h as an opaque struct.

Implement evhttp_bound_socket_get_fd, which returns the file descriptor
of an evhttp_bound_socket.

[Patch from David Reiss]

svn:r1421
2009-08-16 19:21:57 +00:00
Nick Mathewson
7c20a6ae52 Export an ev_socklen_t.
svn:r1391
2009-07-30 17:01:21 +00:00
Nick Mathewson
72ea534f8e Export evutil_str[n]casecmp as evutil_ascii_str[n]casecmp.
svn:r1387
2009-07-28 19:41:57 +00:00
Nick Mathewson
83f46e51d7 Do not use the "evbuffer_" prefix to denote parts of bufferevents.
This is a bit of an interface doozy, but it's really needed in order
to be able to document this stuff without apologizing it.  This patch
does the following renamings:

   evbuffercb -> bufferevent_data_cb
   everrorcb -> bufferevent_event_cb
   EVBUFFER_(READ,WRITE,...) -> BEV_EVENT_(...)
   EVBUFFER_(INPUT,OUTPUT) -> bufferevent_get_(input,output)

All the old names are available in event2/bufferevent_compat.h

svn:r1283
2009-05-13 20:36:56 +00:00
Nick Mathewson
f11dff2c7a Add and use locale-independent strcasecmp functions.
svn:r1280
2009-05-07 03:45:51 +00:00
Nick Mathewson
5a3eddf03f Use fewer _compat.h headers in our own code.
svn:r1268
2009-05-02 16:24:05 +00:00
Nick Mathewson
e865eb938c More msvc build tweaks.
svn:r1262
2009-05-01 00:54:14 +00:00
Nick Mathewson
c5c9589fb0 Add missing case to make http.c compile with warnings enabled.
svn:r1232
2009-04-23 06:27:58 +00:00
Nick Mathewson
9516df0e2e Fix c89 bugs reported by Cory Stup.
Others may remain.  I wasn't able to get gcc --std=c89 to build libevent
at all, so I don't know what compiler the original reporter is using here.

Note that this change requires us to disable the part of our rpc code
that uses variadic macros when using a non-gcc compiler.  This is a
problem if we want our rpc api to be portable.

svn:r1231
2009-04-23 05:40:06 +00:00
Nick Mathewson
a8f6d961eb Actually stop using EVBUFFER_LENGTH/DATA, and move them to buffer_compat.h
svn:r1183
2009-04-17 06:56:09 +00:00
Niels Provos
30648529e8 have evhttp_set_cb return an int; -1 on failure, 0 on success; this is better than returning a pointer
svn:r1179
2009-04-17 01:03:07 +00:00
Niels Provos
d2794e65e0 document evhttp_parse_query better
svn:r1157
2009-04-11 15:26:29 +00:00