140 Commits

Author SHA1 Message Date
Nick Mathewson
f47c15e7ba Make the new http_connect_fail_test use a multicast addr, not broadcast
Turns out that FreeBSD does _not_ give a ENETUNREACH error when
told to make a TCP socket to 255.255.255.255, but it is quite happy
to do so for 239.10.20.30.  So that's what we'll do.

Found by Robert Ransom and Dave Hart.
2011-05-27 23:30:06 -04:00
Kevin Ko
57ddda7845 Test case for 0848814ac49616
"I'm not sure if you'll like my use of the limited broadcast address
  for simulating an ENETUNREACH error with a TCP connection, but it's
  the best that I could think of.  Basically, we want to trigger a
  non-EINPROGRESS error in evutil_socket_connect() immediately at the
  connect() in order to bring about the assertion in the
  evhttp_connection_fail() error handling code."
2011-05-23 01:40:05 -04:00
Nick Mathewson
dd68cce439 Add missing header for regress_http compilation on win32 2011-04-23 01:47:43 -04:00
Sebastian Hahn
b693c324ca Actually send NULL request in http_bad_request_test
Issue caught by clang's static analyzer
2011-04-23 02:04:58 +02: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
6092f1265f Fix http unit test on non-windows platforms without getaddrinfo 2011-01-31 16:37:27 -05:00
Nick Mathewson
22f4af6580 Remove end-of-line whitespace 2010-12-09 11:43:12 -05:00
Constantine Verutin
d23839fc6e Reject overlong http requests early when Expect:100-continue is set 2010-12-07 11:43:52 -05:00
Christopher Davis
fa9305f8f5 Preliminary support for Continue expectation in evhttp. 2010-11-29 18:25:04 -08: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
Kevin Bowling
c2e5e22c4c xlC doesn't obey C99 comments here. autoconf isn't invoking full C99
mode.
2010-11-23 22:24:23 -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
3db6bc0079 Remove some debugging puts() calls from allow_methods test 2010-11-09 10:03:00 -05:00
Nick Mathewson
75e3320efd Units test for unexpected evhttp methods. 2010-11-04 12:41:13 -04:00
Christopher Davis
34b84b9727 Fix more wn64 warnings. 2010-11-03 23:30:29 -04:00
Nick Mathewson
985430aed1 Remove need for http_compat.h in http tests 2010-11-03 15:17:57 -04:00
Nick Mathewson
0b137f452e Stop accessing http request struct directly from in the unit tests. 2010-11-03 15:14:29 -04:00
Nick Mathewson
c91622d18c Stop using event_compat.h in regress_http 2010-11-03 15:04:44 -04:00
Nick Mathewson
9bb8239375 Convert the rest of the http tests to be non-legacy unit tests. 2010-11-03 15:00:08 -04:00
Nick Mathewson
353402a87a Rename the confusing "base" static variable in regress_http.c 2010-11-03 14:13:20 -04:00
Nick Mathewson
8505a7449c Start porting http tests to not use legacy interfaces 2010-11-03 14:11:45 -04:00
Nick Mathewson
bf11e7ddf7 Merge branch 'http_uri_parse' 2010-10-21 15:33:13 -04:00
Nick Mathewson
bc98f5e6ba Unit tests for evhttp_uri_set* 2010-10-21 14:53:21 -04:00
Nick Mathewson
45f6869c75 Make evhttp_uri non-public, and give it accessor functions. 2010-10-21 14:52:52 -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
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
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
eaa5f1d9ed Revise evhttp_uri_parse implementation to handle more of RFC3986 2010-10-19 11:26:59 -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
e5c214a423 Fix -Wsigned-compare warnings in test/* 2010-10-14 13:16:41 -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
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
5b7a370636 Fix warnings on mingw with gcc 4.5 2010-10-05 14:29:48 -04:00
Nick Mathewson
b5dd8064fc Fix uninitialized port var in http_delete_test. Last one, I hope. 2010-09-03 22:00:25 -04:00
Nick Mathewson
3b3fb7438d Fix uninitialized variables in http_bad_request_test. (oops) 2010-09-03 21:03:25 -04:00
Nick Mathewson
a97320ac57 Allow more than one copy of regression tests to run at once
Mostly this was a matter of just removing all the hardwired ports in
the test code.  The http/connection_retry test is still a little
screwy, though.
2010-09-03 18:48:31 -04:00
Nick Mathewson
ec347b9225 Move event-config.h to include/event2
This change means that all required include files are in event2, and
all files not in event2/* are optional.
2010-08-06 20:21:27 -04:00
Nick Mathewson
96730d3191 Make http_base_test stop leaking an event_base. 2010-04-23 23:13:26 -04: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
Nick Mathewson
274a7bd9a1 Fix some memory leaks in the unit tests
These don't matter except inasmuch as they give real memory leaks
a place to hide.

Found with valgrind
2010-03-13 00:56:07 -05:00
Nick Mathewson
2c2618d858 more whitespace normalization 2010-03-05 13:00:15 -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
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
Niels Provos
2f782af35b validate close cb on server when client connection closes 2010-02-13 17:04:17 -08:00
Niels Provos
e8a9782c1d clean up terminate_chunked test 2010-02-13 16:59:37 -08: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