summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2014-11-27 23:59:25 +0100
committerDaniel Stenberg <daniel@haxx.se>2014-12-04 02:52:19 +0100
commit970c22f970f0172e6a4c98ccc3176c740ddaa1c6 (patch)
tree54ecfe7c1eacb1864357725cf4440aff4e0973f3 /configure.ac
parent479abdd32eee15dab78d0cd6b1786d569680f0ac (diff)
downloadcurl-970c22f970f0172e6a4c98ccc3176c740ddaa1c6.tar.gz
libcurl: add UNIX domain sockets support
The ability to do HTTP requests over a UNIX domain socket has been requested before, in Apr 2008 [0][1] and Sep 2010 [2]. While a discussion happened, no patch seems to get through. I decided to give it a go since I need to test a nginx HTTP server which listens on a UNIX domain socket. One patch [3] seems to make it possible to use the CURLOPT_OPENSOCKETFUNCTION function to gain a UNIX domain socket. Another person wrote a Go program which can do HTTP over a UNIX socket for Docker[4] which uses a special URL scheme (though the name contains cURL, it has no relation to the cURL library). This patch considers support for UNIX domain sockets at the same level as HTTP proxies / IPv6, it acts as an intermediate socket provider and not as a separate protocol. Since this feature affects network operations, a new feature flag was added ("unix-sockets") with a corresponding CURL_VERSION_UNIX_SOCKETS macro. A new CURLOPT_UNIX_SOCKET_PATH option is added and documented. This option enables UNIX domain sockets support for all requests on the handle (replacing IP sockets and skipping proxies). A new configure option (--enable-unix-sockets) and CMake option (ENABLE_UNIX_SOCKETS) can disable this optional feature. Note that I deliberately did not mark this feature as advanced, this is a feature/component that should easily be available. [0]: http://curl.haxx.se/mail/lib-2008-04/0279.html [1]: http://daniel.haxx.se/blog/2008/04/14/http-over-unix-domain-sockets/ [2]: http://sourceforge.net/p/curl/feature-requests/53/ [3]: http://curl.haxx.se/mail/lib-2008-04/0361.html [4]: https://github.com/Soulou/curl-unix-socket Signed-off-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac38
1 files changed, 38 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index d2628d132..fb8dfd5b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -154,6 +154,7 @@ dnl initialize all the info variables
curl_tls_srp_msg="no (--enable-tls-srp)"
curl_res_msg="default (--enable-ares / --enable-threaded-resolver)"
curl_ipv6_msg="no (--enable-ipv6)"
+curl_unix_sockets_msg="no (--enable-unix-sockets)"
curl_idn_msg="no (--with-{libidn,winidn})"
curl_manual_msg="no (--enable-manual)"
curl_libcurl_msg="enabled (--disable-libcurl-option)"
@@ -3274,6 +3275,39 @@ if test "$want_tls_srp" = "yes" && ( test "x$HAVE_GNUTLS_SRP" = "x1" || test "x$
fi
dnl ************************************************************
+dnl disable UNIX domain sockets support
+dnl
+AC_MSG_CHECKING([whether to enable UNIX domain sockets])
+AC_ARG_ENABLE(unix-sockets,
+AC_HELP_STRING([--enable-unix-sockets],[Enable UNIX domain sockets])
+AC_HELP_STRING([--disable-unix-sockets],[Disable UNIX domain sockets]),
+[ case "$enableval" in
+ no) AC_MSG_RESULT(no)
+ want_unix_sockets=no
+ ;;
+ *) AC_MSG_RESULT(yes)
+ want_unix_sockets=yes
+ ;;
+ esac ], [
+ AC_MSG_RESULT(auto)
+ want_unix_sockets=auto
+ ]
+)
+if test "x$want_unix_sockets" != "xno"; then
+ AC_CHECK_MEMBER([struct sockaddr_un.sun_path], [
+ AC_DEFINE(USE_UNIX_SOCKETS, 1, [Use UNIX domain sockets])
+ AC_SUBST(USE_UNIX_SOCKETS, [1])
+ curl_unix_sockets_msg="enabled"
+ ], [
+ if test "x$want_unix_sockets" = "xyes"; then
+ AC_MSG_ERROR([--enable-unix-sockets is not available on this platform!])
+ fi
+ ], [
+ #include <sys/un.h>
+ ])
+fi
+
+dnl ************************************************************
dnl disable cookies support
dnl
AC_MSG_CHECKING([whether to enable support for cookies])
@@ -3356,6 +3390,9 @@ fi
if test "x$IPV6_ENABLED" = "x1"; then
SUPPORT_FEATURES="$SUPPORT_FEATURES IPv6"
fi
+if test "x$USE_UNIX_SOCKETS" = "x1"; then
+ SUPPORT_FEATURES="$SUPPORT_FEATURES unix-sockets"
+fi
if test "x$HAVE_LIBZ" = "x1"; then
SUPPORT_FEATURES="$SUPPORT_FEATURES libz"
fi
@@ -3563,6 +3600,7 @@ AC_MSG_NOTICE([Configured to build curl/libcurl:
TLS-SRP support: ${curl_tls_srp_msg}
resolver: ${curl_res_msg}
ipv6 support: ${curl_ipv6_msg}
+ UNIX sockets support: ${curl_unix_sockets_msg}
IDN support: ${curl_idn_msg}
Build libcurl: Shared=${enable_shared}, Static=${enable_static}
Built-in manual: ${curl_manual_msg}