4282 Commits

Author SHA1 Message Date
nntrab
02905413fd Add callback support for error pages
The existing error pages are very basic and don't allow for
multi-lingual support or for conformity with other pages in a web site.
The aim of the callback functionality is to allow custom error pages to
be supported for calls to evhttp_send_error() by both calling
applications and Libevent itself.

A backward-incompatible change has been made to the title of error pages
sent by evhttp_send_error(). The original version of the function used
the reason argument as part of the title. That might have unforeseen
side-effects if it contains HTML tags. Therefore the title has been
changed to always use the standard status text.

An example of the error callback can be found in this
[version](https://github.com/libevent/libevent/files/123607/http-server.zip)
of the 'http-server' sample. It will output error pages with very bright
backgrounds, the error code using a very large font size and the reason.

Closes: #323 (cherr-picked from PR)
2020-01-13 00:50:14 +03:00
Azat Khuzhin
462f2e9766 Merge branch 'http-connect'
After this patchset http-connect works with pproxy [1]:

    $ pproxy -l http://:8000/ -vvv &
    $ http-connect //127.1:8000 http://kernel.org:80/

  [1]: https://pypi.org/project/pproxy/

* http-connect:
  http-connect: do not check connection on GET cb
  http-connect: set Host header (for CONNECT and GET) (like curl)
  http-connect: cleanup and helpers
  http: do not close connection for CONNECT
  http: do not assume body for CONNECT

Fixes: #946
2020-01-12 15:35:10 +03:00
Azat Khuzhin
9c91fe1479 http-connect: do not check connection on GET cb 2020-01-12 15:34:01 +03:00
Azat Khuzhin
415ddee337 http-connect: set Host header (for CONNECT and GET) (like curl) 2020-01-12 15:34:01 +03:00
Azat Khuzhin
e54d5fc57c http-connect: cleanup and helpers 2020-01-12 15:34:01 +03:00
Azat Khuzhin
12ad0c8fcd http: do not close connection for CONNECT 2020-01-12 15:34:01 +03:00
Azat Khuzhin
998e68340e http: do not assume body for CONNECT 2020-01-12 15:33:59 +03:00
Dimo Markov
f0e79bafd8 Added uninstall target check to cmakelists 2020-01-08 20:37:16 +02:00
Azat Khuzhin
08981f8d75 Fix compilation without OPENSSL_API_COMPAT
Use the following for openssl 1.1+:
- X509_getm_notBefore over X509_get_notBefore
- X509_getm_notAfter  over X509_get_notAfter
- use OPENSSL_VERSION_NUMBER over SSLeay()
- add missing headers

Refs: openssl/openssl@0b7347effe
2020-01-07 22:15:08 +03:00
yuangongji
6412f34f24 evutil_time: Implements usleep() using wait funtion on Windows 2019-12-31 00:37:29 +03:00
yangyongsheng
1edb6f6188 Initialize variable to 0 replace use memset function in sample/hello-world.c 2019-12-30 10:09:15 +08:00
Azat Khuzhin
ea12428db6 appveyor: switch to Previous Visual Studio 2019 (VS issues after update)
After update [1] of the Visual Studio 2019 image cmake unable to find
path to the c compiler [2]:

    cmake : CMake Error at CMakeLists.txt:47 (project):
    At line:1 char:1
    + cmake -G 'Visual Studio 16 2019' -A x64 ..
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (CMake Error at ...t:47 (project)::String) [], RemoteException
        + FullyQualifiedErrorId : NativeCommandError

      The CMAKE_C_COMPILER:
        C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.23.28105/bin/Hostx64/x64/cl.exe
      is not a full path to an existing compiler tool.

  [1]: https://github.com/appveyor/ci/issues/3231
       https://www.appveyor.com/updates/2019/12/09/
  [2]: https://ci.appveyor.com/project/libevent/libevent/builds/29431286/job/a68h7dn9rcride9g
2019-12-10 09:29:08 +03:00
Andre Pereira Azevedo Pinto
f76456b0dc Add support for priority inheritance
Add support for posix mutex priority inheritance. This is important to
avoid priority inversion in systems running with threads with different
priorities.

Signed-off-by: Andre Azevedo <andre.azevedo@gmail.com>
2019-12-09 14:55:31 -08:00
Azat Khuzhin
8f13c170cf cmake: set CMAKE_{RUNTIME,LIBRARY,ARCHIVE}_OUTPUT_DIRECTORY they are not defined
This will allow overriding them in parent cmake rules, i.e. if libevent
is used via add_subdirectory().

Closes: #931
2019-11-30 15:58:17 +03:00
Azat Khuzhin
b9f442e2d7 cmake: use CMAKE_LIBRARY_OUTPUT_DIRECTORY for the final shared library symlink
Fixes: 669a53f3 ("cmake: set library names to be the same as with autotools")
2019-11-30 15:54:56 +03:00
Azat Khuzhin
aff231229e appveyor: fix EVENT_CMAKE_OPTIONS expansion (for multiple arguments)
Fixes: 63f73ee2 ("CI: integrate testing for components export")
2019-11-17 23:31:14 +03:00
Azat Khuzhin
8a34869984 test-ratelim: calculate timers bias (for slow CPUs) to avoid false-positive
This can be/should be done for regression tests too.

Refs: https://ci.appveyor.com/project/libevent/libevent/builds/28916689/job/kg621aa194a0qbym
Refs: https://github.com/libevent/libevent/pull/917#issuecomment-553811834
v2: EVENT_BASE_FLAG_PRECISE_TIMER
2019-11-17 20:52:28 +03:00
Azat Khuzhin
026590f908 mailmap: add name/email aliases for yuangongji (name and email)
Before:
  $ git log --format='%aE %aN' --author=yuangongji | sort | uniq -c
       30 82787816@qq.com yuangongji
        1 82787816@qq.com yuangongji (A)

After:
  $ git log --format='%aE %aN' --author=yuangongji | sort | uniq -c
       34 yuangongji@foxmail.com yuangongji
2019-11-17 15:51:07 +03:00
Azat Khuzhin
8be8ac4602 Merge #929 -- cmake package improvements
Example:

  find_package(Libevent 2.2.0 REQUIRED COMPONENTS core)
  add_executable(test test.c)
  target_link_libraries(test ${LIBEVENT_LIBRARIES})

* upstream/pr/929:
  CI: integrate testing for components export
  cmake: test for find_package()
  cmake: improve package config file
2019-11-17 02:45:54 +03:00
yuangongji
02dc7a1b17 appveyor: fix openssl version mismatch warning
yuangongji:

  "Many warnings appear when building and running with Visual Studio 2019 in Appveyor:

   WARN C:\projects\libevent\test\regress_ssl.c:210: Version mismatch for openssl: compiled with 1000214f but running with 1000212f

   Simply add the openssl binary to the "PATH" environment variable to fix it.

   I wrote a simple demo to reproduce it: https://github.com/ygj6/verify
   I see there are dozens of openssl libraries in the system of appveyor: https://ci.appveyor.com/project/ygj6/verify/builds/28290688
   If you do not specify which openssl to use, the system cannot find the correct library."
2019-11-17 02:42:42 +03:00
Azat Khuzhin
28ba0a4797 appveyor: disable parallel tests execution
Refs: https://github.com/libevent/libevent/pull/917#issuecomment-553784701
2019-11-17 02:42:41 +03:00
yuangongji
63f73ee2ad CI: integrate testing for components export 2019-11-15 22:00:41 +08:00
yuangongji
cd15112b62 cmake: test for find_package() 2019-11-14 18:28:31 +08:00
yuangongji
dc4be869d5 cmake: improve package config file 2019-11-14 18:09:31 +08:00
Azat Khuzhin
1495f8b67a Link with iphlpapi only on windows
Fixes: 9fecb59a ("Parse IPv6 scope IDs.")
Refs: #923
2019-11-06 21:44:30 +03:00
Philip Homburg
9fecb59a94 Parse IPv6 scope IDs. 2019-11-06 21:07:16 +03:00
Azat Khuzhin
4436287d12 Relax bufferevent_connect_hostname_emfile
Do not do any assumptions on the error for the EMFILE from
getaddrinfo(), expect just any error.

Fixes: #924
2019-10-31 09:20:49 +03:00
yuangongji
53b3be4ee9 autotools: fails build when need but can not find openssl 2019-10-26 22:43:26 +08:00
yuangongji
5fe83d7433 cmake: eliminate duplicate installation of public headers 2019-10-25 21:54:13 +08:00
Azat Khuzhin
1ba94bdf08 Merge pull request #915 from ygj6 -- evutil_socketpair win32 fixes
* upstream/pr/915:
  appveyor: add vs2019 os to test some new features brought by Win10
  test: add testcase for evutil_socketpair()
  evutil: make evutil_socketpair() have the same behavior on Windows with build number lower and higher than 17063
2019-10-21 22:21:19 +03:00
Michael Davidsaver
84affc1837 append to CMAKE_MODULE_PATH
Don't override any -DCMAKE_MODULE_PATH= passed from CLI
to eg. test custom Platform/ support.
2019-10-21 10:41:27 -07:00
yuangongji
38eb4846e2 appveyor: add vs2019 os to test some new features brought by Win10 2019-10-19 13:16:25 +08:00
yuangongji
55d60c9258 test: add testcase for evutil_socketpair() 2019-10-19 13:07:04 +08:00
yuangongji
879d249619 evutil: make evutil_socketpair() have the same behavior on Windows with build number lower and higher than 17063 2019-10-18 21:03:40 +08:00
Azat Khuzhin
b9b9f19058 Do not use sysctl.h on linux (it had been deprecated)
It had been deprecated for a long time (AFAIK), but since
glibc-2.29.9000-309-g744e829637 it produces a #warning
2019-10-16 01:11:51 +03:00
yuangongji
dda8968c71 evutil: implement socketpair with unix domain socket on Win10 2019-10-14 23:23:56 +03:00
Azat Khuzhin
11bdd41c56 travis-ci: add OPENSSL_1_1=yes for the openssl 1.1 to distinguish it in list 2019-10-14 23:22:55 +03:00
Azat Khuzhin
fb95772ac7 travis-ci: use matrix.include over env.matrix/matrix.exclude for coveralls 2019-10-14 23:20:44 +03:00
Azat Khuzhin
f2bdd6eea1 travis-ci: build with clang only basic configurations
I tried to exclude clang instead (for PRs), but matrix.exclude cannot
have conditions (i..e matrix.exclude.if).
2019-10-14 23:20:20 +03:00
Azat Khuzhin
c1c8ae714b Use matrix.include.if over matrix.exclude.if for doxygen
And use if.repo over if.slug

Fixes: aeb014cc ("Do not try to deploy documentaion for PR")
2019-10-14 22:24:37 +03:00
Azat Khuzhin
aeb014cc05 Do not try to deploy documentaion for PR
Anyway access to security variables is forbidden for PRs.

v2: use travis-ci conditions, to avoid running addons
2019-10-14 03:05:41 +03:00
Azat Khuzhin
b32a644302 Fix all all yamllint warnings in travis/appveyor rules 2019-10-09 00:19:17 +03:00
Azat Khuzhin
c88c578ac3 appveyor: do not allow any failures
Yes we still have flacky tests, but anyway two main configuration can
fail too (and they do fail from time to time) so let's not allow any
failures and see how this will go.

(Credits to @ygj6 via #910)
2019-10-09 00:13:33 +03:00
yuangongji
72d140c2e1 appveyor: fix build script for compiling using mingw-w64 2019-10-08 22:01:01 +08:00
yuangongji
78b5bca6d8 sample/https-client: link crypt32 explicitly when build with mingw-w64 2019-10-08 21:38:58 +08:00
Azat Khuzhin
c328999e5d Merge remote-tracking branch 'upstream/pr/908'
* upstream/pr/908:
  Avoid transforming base C_FLAGS set deliberately
2019-10-07 22:10:14 +03:00
Kamil Rytarowski
72e6eff025 Fix compat with NetBSD >= 10
kevent::udata was switched from intptr_t to void*.

Handle both cases with the GCC extension typeof().
2019-10-04 01:30:39 +02:00
William A Rowe Jr
af4b07a55c Avoid transforming base C_FLAGS set deliberately
The CMAKE_C_FLAGS_DEBUG, CMAKE_C_FLAGS_RELEASE, CMAKE_C_FLAGS_MINSIZEREL
and CMAKE_C_FLAGS_RELWITHDEBINFO options are correctly and deliberately
toggled to use the libcmt (/MT) flag options in place of the usual
msvcrt (/MD) options, but this isn't necessarily desired by the user.
The default choice can be overriden with the EVENT__MSVC_STATIC_RUNTIME
cmake option.

However, the /MD flag that is the choice of CMake only enters into
play for the four types of builds above. If the user introduces another
CMAKE_BUILD_TYPE, the base CMAKE_C_FLAGS must not be manipulated, as
that value (and the CMAKE_C_FLAGS_{custom} value) have been explicitly
chosen by the user/developer deploying this library, and the mismatch
between these flags in different dependencies results in link errors.

The CMake build schema itself doesn't place an /MD flag in CMAKE_BUILD_TYPE
so any /M compile option in that variable needs to be retained.

Signed-off-by: William Rowe <wrowe@pivotal.io>
Signed-off-by: Yechiel Kalmenson <ykalmenson@pivotal.io>
2019-10-03 11:40:52 -07:00
yuangongji
8d5c5650d2 tinytest: support timeout on Windows 2019-09-26 21:54:33 +08:00
Azat Khuzhin
a977d69636
Merge branch 'upstream/pr/899' (evbuffer_freeze testcase enhancements)
* upstream/pr/899:
  improve the description of parameter to evbuffer_read()
  regress_buffer: improve testcase for evbuffer_freeze()
2019-09-22 18:45:21 +03:00