+/* {{{ cruft for thread safe SSL crypto locks */
+#if defined(ZTS) && defined(HTTP_HAVE_SSL)
+# ifdef PHP_WIN32
+# define HTTP_NEED_SSL_TSL
+# define HTTP_NEED_OPENSSL_TSL
+# include <openssl/crypto.h>
+# else /* !PHP_WIN32 */
+# if defined(HTTP_HAVE_OPENSSL)
+# if defined(HAVE_OPENSSL_CRYPTO_H)
+# define HTTP_NEED_SSL_TSL
+# define HTTP_NEED_OPENSSL_TSL
+# include <openssl/crypto.h>
+# else
+# warning \
+ "libcurl was compiled with OpenSSL support, but configure could not find " \
+ "openssl/crypto.h; thus no SSL crypto locking callbacks will be set, which may " \
+ "cause random crashes on SSL requests"
+# endif
+# elif defined(HTTP_HAVE_GNUTLS)
+# if defined(HAVE_GCRYPT_H)
+# define HTTP_NEED_SSL_TSL
+# define HTTP_NEED_GNUTLS_TSL
+# include <gcrypt.h>
+# else
+# warning \
+ "libcurl was compiled with GnuTLS support, but configure could not find " \
+ "gcrypt.h; thus no SSL crypto locking callbacks will be set, which may " \
+ "cause random crashes on SSL requests"
+# endif
+# else
+# warning \
+ "libcurl was compiled with SSL support, but configure could not determine which" \
+ "library was used; thus no SSL crypto locking callbacks will be set, which may " \
+ "cause random crashes on SSL requests"
+# endif /* HTTP_HAVE_OPENSSL || HTTP_HAVE_GNUTLS */
+# endif /* PHP_WIN32 */
+#endif /* ZTS && HTTP_HAVE_SSL */
+
+#ifdef HTTP_NEED_SSL_TSL
+static inline void http_ssl_init(void);
+static inline void http_ssl_cleanup(void);
+#endif
+/* }}} */
+
+/* {{{ MINIT */
+PHP_MINIT_FUNCTION(http_request)
+{
+#ifdef HTTP_NEED_SSL_TSL
+ http_ssl_init();
+#endif
+
+ if (CURLE_OK != curl_global_init(CURL_GLOBAL_ALL)) {
+ return FAILURE;
+ }
+
+ HTTP_LONG_CONSTANT("HTTP_AUTH_BASIC", CURLAUTH_BASIC);
+ HTTP_LONG_CONSTANT("HTTP_AUTH_DIGEST", CURLAUTH_DIGEST);
+ HTTP_LONG_CONSTANT("HTTP_AUTH_NTLM", CURLAUTH_NTLM);
+ HTTP_LONG_CONSTANT("HTTP_AUTH_ANY", CURLAUTH_ANY);
+
+ HTTP_LONG_CONSTANT("HTTP_VERSION_NONE", CURL_HTTP_VERSION_NONE);
+ HTTP_LONG_CONSTANT("HTTP_VERSION_1_0", CURL_HTTP_VERSION_1_0);
+ HTTP_LONG_CONSTANT("HTTP_VERSION_1_1", CURL_HTTP_VERSION_1_1);
+
+ return SUCCESS;
+}
+/* }}} */
+
+/* {{{ MSHUTDOWN */
+PHP_MSHUTDOWN_FUNCTION(http_request)
+{
+ curl_global_cleanup();
+#ifdef HTTP_NEED_SSL_TSL
+ http_ssl_cleanup();
+#endif
+ return SUCCESS;
+}
+/* }}} */
+
+/* {{{ MACROS */
+#ifndef HAVE_CURL_EASY_STRERROR
+# define curl_easy_strerror(dummy) "unkown error"