3103 Commits

Author SHA1 Message Date
Azat Khuzhin
862c217a29 Add test for EVREQ_HTTP_REQUEST_CANCEL into http_cancel_test() 2013-04-25 15:12:20 -04:00
Azat Khuzhin
7b077194cc Add new error_cb for actual reporting of HTTP request errors.
It is useful to know why you callback called with NULL (i.e. it failed),
for example if you set max_body with evhttp_connection_set_max_body_size()
you must know that it failed because of body was longer than this size.

 (Commit message tweaked by Nick)
2013-04-25 15:11:44 -04:00
Nick Mathewson
ed26561b0c Fix another warning introduced in 0c6ec5d8 2013-04-25 14:48:56 -04:00
Nick Mathewson
eeb700ce31 Fix a warning introduced in 0c6ec5d8 2013-04-25 14:47:26 -04:00
Nick Mathewson
6b94ffcec5 Merge remote-tracking branch 'origin/patches-2.0'
Conflicts:
	configure.ac
2013-04-25 13:54:19 -04:00
Nick Mathewson
66dacfa2a5 Merge remote-tracking branch 'origin/pr/36' into patches-2.0 2013-04-25 13:43:49 -04:00
Nick Mathewson
eb6b0c1f90 Merge branch '21_evdns_disable_when_inactive' 2013-04-25 10:47:16 -04:00
Azat Khuzhin
6b7fa620e8 evdns: New flag to make evdns not prevent the event loop from exiting
Here is the brief description of problem:
When you are use evdns to resolve domains to IP adresses (see
./sample/dns-example) you loop never returns from event_base_dispatch(),
and because of this the program will never terminated.

Because existing programs may be depending on the old behavior, we
only apply the fix when evdns_base_new() is created with a new flag -
EVDNS_BASE_DISABLE_WHEN_INACTIVE.

 (Commit message edited by Nick while squashing the branch.)
2013-04-25 10:43:12 -04:00
Nick Mathewson
5e6fa2a3ab event_base_update_cache_time should be a no-op if the loop isn't running 2013-04-24 13:23:15 -04:00
Nick Mathewson
1c3147f5e7 Add a test with an active_later event at event_base_free time. 2013-04-10 18:03:16 -04:00
Nick Mathewson
95acdaa353 Another tweak to https-client.c 2013-04-10 17:56:54 -04:00
Nick Mathewson
8a90a850fc Remove http_struct.h usage in sample/https-client.c 2013-04-10 13:53:44 -04:00
Nick Mathewson
2fad0f3d52 Add an environment variable (EVENT_DEBUG_MODE) to run unit tests in debug mode
Not all tests currently pass with debug mode on.
2013-04-05 15:06:54 -04:00
Nick Mathewson
3339800854 Merge branch '21_empty_strlcpy' 2013-04-01 11:59:26 -04:00
Nick Mathewson
4914620025 Do not build strlcpy.c when it will have no code. 2013-03-31 14:05:26 -04:00
Nick Mathewson
e834006b61 Merge pull request #75 from altf4/master
Header update to specify evbuffer_pullup() behavior
2013-03-29 09:39:52 -07:00
Dan Petro
cf8d1cdb20 Specify return behavior in header for evbuffer_pullup() in corner case
Function returns NULL when told to pullup more data than exists
2013-03-29 09:28:35 -07:00
Nick Mathewson
81ea0c4c7a Merge pull request #47 from ppelleti/https
HTTPS example adapted from Catalin
2013-03-28 05:57:07 -07:00
Nick Mathewson
1bc4a8f99d Merge remote-tracking branch 'origin/patches-2.0' 2013-03-25 21:14:10 -04:00
Nick Mathewson
773b0a5d88 Fix a typo in a comment in buffer.h. Spotted by Alt_F4 2013-03-25 21:12:49 -04:00
Nick Mathewson
f935e2159a build test/test-script.sh on systems with a less-featureful $< 2013-03-15 09:33:28 -04:00
Nick Mathewson
787fd7489f Make --disable-libevent-regress work again 2013-03-15 09:33:13 -04:00
Nate Rosenblum
9443868d55 Double-check next timeout when adding events
When resuming the system from a suspended state, the ev_timeout field
of a scheduled timer event may be in the past. This leads to
unexpected behavior when scheduling a short-duration timer event
immediately after returning from suspension, because the new event
does not land on top of the timeout minheap and so the event loop
(blocked on a possibly long-duration timeout) is not notified.

This patch checks for this condition and, if it obtains, notifies the
event loop.
2013-03-05 11:29:33 -08:00
Azat Khuzhin
13676535c8 Test: decoding just part of string with evhttp_decode_uri_internal() 2013-03-01 12:02:54 +04:00
Azat Khuzhin
de8101a884 Move prototype of evhttp_decode_uri_internal() to http-internal.h
Make it non static, that can be called from tests
2013-03-01 12:00:24 +04:00
Azat Khuzhin
e1903e3ace uri decode: changed the test for the existence of the next character
Fix for 64b6eceaba1a4

More info here
64b6eceaba (commitcomment-2714685)
2013-02-28 23:10:02 +04:00
Azat Khuzhin
64b6eceaba uri decode: fix for warning "use of uninitialised value"
This patch add check in evhttp_decode_uri_internal() that next 2 symbols
are exists in array of chars for decoding, if don't have two next 2
symbols don't try to decode '%FF'
2013-02-28 17:19:44 +04:00
Patrick Pelletier
4db9da6bbf pull in wildcard matching code from cURL
Now, https-client accepts both:

https://ip.appspot.com/ (matching wildcard certificate)
https://github.com/     (matching non-wildcard certificate)

but still rejects

https://www.kegel.com/  (non-matching wildcard certificate)

which should match the behavior of these sites in a web browser.
2013-02-27 21:22:03 -08:00
Patrick Pelletier
6021cb5027 avoid sign mismatch warning in openssl_hostname_validation.c
sample/openssl_hostname_validation.c: In function 'matches_common_name':
sample/openssl_hostname_validation.c:80: warning: comparison between signed and unsigned integer expressions
sample/openssl_hostname_validation.c: In function 'matches_subject_alternative_name':
sample/openssl_hostname_validation.c:124: warning: comparison between signed and unsigned integer expressions
2013-02-27 21:22:03 -08:00
Patrick Pelletier
64d9f161fe use iSECPartners code to validate hostname in certificate
The problem is that if you go to a website whose certificate does not
match its hostname, it should fail.  Try this in a web browser for
https://www.kegel.com/ for example.  Your web browser will say the
certificate is for *.pair.com, not for www.kegel.com, and won't let
you visit it without clicking through a bunch of scary warnings.

However, prior to this commit, https-client was happy to fetch
https://www.kegel.com/ without complaining.  That is bad.  Now, with
this commit, it will properly complain, which is good:

pelletier@chives:~/src/libevent/sample$ ./https-client https://www.kegel.com/
Got 'MatchNotFound' for hostname 'www.kegel.com' and certificate:
/C=US/postalCode=15203/ST=Pennsylvania/L=Pittsburgh/street=Suite 210/street=2403 Sidney Street/O=pair Networks, Inc./OU=Provided by pair Networks, Inc./OU=PairWildcardSSL $250,000/CN=*.pair.com
some request failed - no idea which one though!
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
ppelletier@chives:~/src/libevent/sample$

It will still succeed for sites with an exactly-matching certificate,
such as https://github.com/ and that is also good!

However, the problem is that the iSECPartners code doesn't handle
wildcards, which means we reject https://ip.appspot.com/ even though
it is perfectly legitimate, because we don't understand the wildcard:

ppelletier@chives:~/src/libevent/sample$ ./https-client https://ip.appspot.com/
Got 'MatchNotFound' for hostname 'ip.appspot.com' and certificate:
/C=US/ST=California/L=Mountain View/O=Google Inc/CN=*.appspot.com
some request failed - no idea which one though!
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
ppelletier@chives:~/src/libevent/sample$

So, we need to fix this.  In other words, "to be continued..."
2013-02-27 21:22:03 -08:00
Patrick Pelletier
aacd674c94 use Debian's default root certificate location
as suggested here:
http://archives.seul.org/libevent/users/Feb-2013/msg00034.html

although curl's acinclude.m4 reveals many other possibilities:

dnl /etc/ssl/certs/ca-certificates.crt Debian systems
dnl /etc/pki/tls/certs/ca-bundle.crt Redhat and Mandriva
dnl /usr/share/ssl/certs/ca-bundle.crt old(er) Redhat
dnl /usr/local/share/certs/ca-root.crt FreeBSD
dnl /etc/ssl/cert.pem OpenBSD
dnl /etc/ssl/certs/ (ca path) SUSE

And none of these cover Windows :(
2013-02-27 21:22:03 -08:00
Patrick Pelletier
5754d96a6e better handling of OpenSSL errors 2013-02-27 21:22:03 -08:00
Patrick Pelletier
42d7441ac4 https-client was putting newlines at 256-byte boundaries
presumably this was meant to put a ">" before every line, but that
isn't what it does, since evbuffer_remove is simply returning
fixed-size chunks.  So, when retrieving a document of more than 256
bytes (e. g. any nontrivial document), we got "> " and newlines thrown
in at very arbitrary places.
2013-02-27 21:22:03 -08:00
Patrick Pelletier
bf31fa5d30 use ${OPENSSL_LIBS} instead of -lssl -lcrypto
This made the difference between segfaulting and not segfaulting for
me when I run https-client, when I've built libevent using an OpenSSL
in a non-standard location.

In the same spirit as 1d9d5110a4aebf5833f6fd78bd0252affde0f4d0 and
d70af27d0152d0a87a25127faf215604beb8ffe0.
2013-02-27 21:22:03 -08:00
Catalin Patulea
be46c99b89 Add sample/https-client.c, an example of stacking evhttp as a client on top of bufferevent_ssl.
Signed-off-by: Catalin Patulea <catalinp@google.com>
2013-02-27 16:06:56 -08:00
Nick Mathewson
87c56727b6 Merge pull request #41 from ppelleti/winsock-errs
FormatMessage for winsock errors
2013-02-26 15:22:03 -08:00
Patrick Pelletier
c9ad3af229 test filling up the hash table a bit 2013-02-25 20:13:01 -08:00
Patrick Pelletier
4ccdd53f78 use hashtable instead of linked list to cache winsock errors
as discussed here:
https://github.com/libevent/libevent/pull/41#issuecomment-13611817
2013-02-25 19:02:32 -08:00
Patrick Pelletier
2078e9b46a make sure caching works, and we don't leak memory 2013-02-14 20:26:38 -08:00
Patrick Pelletier
0c6ec5d816 use FormatMessage for winsock errors
as discussed here:
http://archives.seul.org/libevent/users/Feb-2013/msg00004.html
2013-02-14 20:26:38 -08:00
Patrick Pelletier
729651260d a program to print out the error strings for winsock errors 2013-02-14 18:22:12 -08:00
Nick Mathewson
9709461457 Merge remote-tracking branch 'origin/patches-2.0' 2013-02-14 14:13:11 -05:00
Greg Hazel
b618204216 fix #73 and fix http_connection_fail_test to catch it 2013-02-14 09:54:56 -08:00
Nick Mathewson
96150dd0c6 Unit test for event_remove_timer with EV_PERSIST.
Patch from dcicppin on sourceforge.
2013-02-13 11:41:11 -05:00
Nick Mathewson
5623e80371 Make event_remove_timer behave correctly with persistent timers 2013-02-13 11:41:11 -05:00
Nick Mathewson
74e52db45d Merge remote-tracking branch 'ppelleti/nmake-clean-exes' 2013-02-11 11:25:25 -05:00
Nick Mathewson
2863c83700 Avoid using $(top_srcdir) in TESTS.
Newer automakes don't like this.
2013-02-08 22:10:05 -05:00
Nick Mathewson
ebf278b28d Use AC_CONFIG_HEADERS in place of AM_CONFIG_HEADERS for autmake 1.13 compat
Patch from cazfi.
2013-02-08 22:09:56 -05:00
Nick Mathewson
d670e3bd35 Merge remote-tracking branch 'origin/patches-2.0'
This is an "ours" commit: I'm not taking the recent autotools changes
from patches-2.0, since they'd conflict with master.
2013-02-08 22:09:00 -05:00
Nick Mathewson
a55514eeed Avoid using top_srcdir in TESTS-new automakes do not like this 2013-02-08 22:08:18 -05:00