/* * call-seq: * Curl.asyncdns? => true or false * * Returns true if the installed libcurl was built with support for * asynchronous name lookups, which allows more exact timeouts (even * on Windows) and less blocking when using the multi interface. * For libcurl versions < 7.10.7, always returns false. */ static VALUE ruby_curl_asyncdns_q(VALUE mod) { #ifdef HAVE_CURL_VERSION_ASYNCHDNS curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW); return((ver->features & CURL_VERSION_ASYNCHDNS) ? Qtrue : Qfalse); #else return Qfalse; #endif }
/* * call-seq: * Curl.debug? => true or false * * Returns true if the installed libcurl was built with extra debug * capabilities built-in. For libcurl versions < 7.10.6, always returns * false. */ static VALUE ruby_curl_debug_q(VALUE mod) { #ifdef HAVE_CURL_VERSION_DEBUG curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW); return((ver->features & CURL_VERSION_DEBUG) ? Qtrue : Qfalse); #else return Qfalse; #endif }
/* * call-seq: * Curl.largefile? => true or false * * Returns true if the installed libcurl was built with support for large * files. For libcurl versions < 7.11.1, always returns false. */ static VALUE ruby_curl_largefile_q(VALUE mod) { #ifdef HAVE_CURL_VERSION_LARGEFILE curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW); return((ver->features & CURL_VERSION_LARGEFILE) ? Qtrue : Qfalse); #else return Qfalse; #endif }
/* * call-seq: * Curl.spnego? => true or false * * Returns true if the installed libcurl was built with support for SPNEGO * authentication (Simple and Protected GSS-API Negotiation Mechanism, defined * in RFC 2478). For libcurl versions < 7.10.8, always returns false. */ static VALUE ruby_curl_spnego_q(VALUE mod) { #ifdef HAVE_CURL_VERSION_SPNEGO curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW); return((ver->features & CURL_VERSION_SPNEGO) ? Qtrue : Qfalse); #else return Qfalse; #endif }
int main (int argc, char *const *argv) { unsigned int errorCount = 0; const char *ssl_version; /* initialize random seed used by curl clients */ unsigned int iseed = (unsigned int) time (NULL); #ifdef GCRYCTL_INITIALIZATION_FINISHED gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif srand (iseed); ssl_version = curl_version_info (CURLVERSION_NOW)->ssl_version; if (NULL == ssl_version) { fprintf (stderr, "Curl does not support SSL. Cannot run the test.\n"); return 0; } if (0 != strncmp (ssl_version, "GnuTLS", 6)) { fprintf (stderr, "This test can be run only with libcurl-gnutls.\n"); return 0; } if (0 != curl_global_init (CURL_GLOBAL_ALL)) { fprintf (stderr, "Error: %s\n", strerror (errno)); return -1; } char *aes256_sha = "AES256-SHA"; if (curl_uses_nss_ssl() == 0) { aes256_sha = "rsa_aes_256_sha"; } errorCount += test_wrap ("multi threaded daemon, single client", &test_single_client, NULL, MHD_USE_TLS | MHD_USE_DEBUG | MHD_USE_THREAD_PER_CONNECTION, aes256_sha, CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, MHD_OPTION_END); errorCount += test_wrap ("multi threaded daemon, parallel client", &test_parallel_clients, NULL, MHD_USE_TLS | MHD_USE_DEBUG | MHD_USE_THREAD_PER_CONNECTION, aes256_sha, CURL_SSLVERSION_TLSv1, MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem, MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem, MHD_OPTION_END); if (errorCount != 0) fprintf (stderr, "Failed test: %s.\n", argv[0]); curl_global_cleanup (); return errorCount != 0; }
static void _thread_init(LogThrDestDriver *s) { HTTPDestinationDriver *self = (HTTPDestinationDriver *) s; curl_version_info_data *curl_info = curl_version_info(CURLVERSION_NOW); if (!self->user_agent) self->user_agent = g_strdup_printf("syslog-ng %s/libcurl %s", SYSLOG_NG_VERSION, curl_info->version); }
/* **************************************************************************** * * curlVersionGet - */ static char* curlVersionGet(char* buf, int bufLen) { curl_version_info_data* idP; idP = curl_version_info(CURLVERSION_NOW); snprintf(buf, bufLen, "%s", idP->version); return buf; }
CURLcode get_libcurl_info(void) { static struct proto_name_pattern { const char *proto_name; long proto_pattern; } const possibly_built_in[] = { { "dict", CURLPROTO_DICT }, { "file", CURLPROTO_FILE }, { "ftp", CURLPROTO_FTP }, { "ftps", CURLPROTO_FTPS }, { "gopher", CURLPROTO_GOPHER }, { "http", CURLPROTO_HTTP }, { "https", CURLPROTO_HTTPS }, { "imap", CURLPROTO_IMAP }, { "imaps", CURLPROTO_IMAPS }, { "ldap", CURLPROTO_LDAP }, { "ldaps", CURLPROTO_LDAPS }, { "pop3", CURLPROTO_POP3 }, { "pop3s", CURLPROTO_POP3S }, { "rtmp", CURLPROTO_RTMP }, { "rtsp", CURLPROTO_RTSP }, { "scp", CURLPROTO_SCP }, { "sftp", CURLPROTO_SFTP }, { "smb", CURLPROTO_SMB }, { "smbs", CURLPROTO_SMBS }, { "smtp", CURLPROTO_SMTP }, { "smtps", CURLPROTO_SMTPS }, { "telnet", CURLPROTO_TELNET }, { "tftp", CURLPROTO_TFTP }, { NULL, 0 } }; struct proto_name_pattern const *p; const char *const *proto; /* Pointer to libcurl's run-time version information */ curlinfo = curl_version_info(CURLVERSION_NOW); if(!curlinfo) return CURLE_FAILED_INIT; /* Build CURLPROTO_* bit pattern with libcurl's built-in protocols */ built_in_protos = 0; if(curlinfo->protocols) { for(proto = curlinfo->protocols; *proto; proto++) { for(p = possibly_built_in; p->proto_name; p++) { if(curlx_raw_equal(*proto, p->proto_name)) { built_in_protos |= p->proto_pattern; break; } } } } return CURLE_OK; }
int InitThreadPool() { curl_version_info_data* info = curl_version_info(CURLVERSION_NOW); //if (info->features & CURL_VERSION_ASYNCHDNS) //std::cout << "ares enabled" << endl; //else //std::cout << "ares NOT enabled" << endl; g_threadpool = (struct threadpool *) threadpool_init(POOL_THREAD_NUM, POOL_QUEUE_NUM); curl_global_init(CURL_GLOBAL_ALL); return 0; }
/** * Check if the given string is a protocol supported by libcurl * * @param str the protocol name * @return PARAM_OK protocol supported * @return PARAM_LIBCURL_UNSUPPORTED_PROTOCOL protocol not supported * @return PARAM_REQUIRES_PARAMETER missing parameter */ int check_protocol(const char *str) { const char * const *pp; const curl_version_info_data *curlinfo = curl_version_info(CURLVERSION_NOW); if(!str) return PARAM_REQUIRES_PARAMETER; for(pp = curlinfo->protocols; *pp; pp++) { if(curl_strequal(*pp, str)) return PARAM_OK; } return PARAM_LIBCURL_UNSUPPORTED_PROTOCOL; }
/* 初始化HttpClient,使用前务必调用 */ void HttpClient_Init(HttpClient *client) { //{{{ curl_version_info_data *version; if (client->curl == NULL) { client->curl = curl_easy_init(); client->responseText = HttpBuffer_New(); client->responseHeader = HttpBuffer_New(); } else { curl_easy_reset(client->curl); } /* 重置失败次数 */ client->fail_times = 0; client->retry_times = 5; client->retry_interval = 1; /* 重置失败回调 */ client->fail_reset_callback = NULL; client->fail_reset_context = NULL; /* 清空body cstr */ if (client->c_responseText != NULL) { free(client->c_responseText); client->c_responseText = NULL; } /* 清空header cstr */ if (client->c_responseHeader != NULL) { free(client->c_responseText); client->c_responseText = NULL; } /* curl 初始化 */ curl_easy_setopt(client->curl, CURLOPT_WRITEFUNCTION, _HttpClient_WriteData); curl_easy_setopt(client->curl, CURLOPT_WRITEDATA, client); curl_easy_setopt(client->curl, CURLOPT_SSL_VERIFYPEER, 0); curl_easy_setopt(client->curl, CURLOPT_SSL_VERIFYHOST, 0); /* 选个快点的加密算法 */ version = curl_version_info(CURLVERSION_NOW); if (strstr(version->ssl_version, "OpenSSL") != NULL) { curl_easy_setopt(client->curl, CURLOPT_SSL_CIPHER_LIST, "RC4-SHA"); } else if (strstr(version->ssl_version, "NSS") != NULL) { curl_easy_setopt(client->curl, CURLOPT_SSL_CIPHER_LIST, "rc4,rsa_rc4_128_sha"); } /* 设置默认超时时间 */ curl_easy_setopt(client->curl, CURLOPT_TIMEOUT, 20); curl_easy_setopt(client->curl, CURLOPT_CONNECTTIMEOUT, 5); }
TEST(Versions, CurlSslStatic) { curl_version_info_data * vinfo = curl_version_info(CURLVERSION_NOW); // Check that SSL support is enabled when required bool curlSupportsSsl = vinfo->features & CURL_VERSION_SSL; #if ORTHANC_SSL_ENABLED == 0 ASSERT_FALSE(curlSupportsSsl); #else ASSERT_TRUE(curlSupportsSsl); #endif }
/* Module initialization function */ static int mod_init(void) { LM_DBG("init curl module\n"); /* Initialize curl */ if (curl_global_init(CURL_GLOBAL_ALL)) { LM_ERR("curl_global_init failed\n"); return -1; } curl_info = curl_version_info(CURLVERSION_NOW); if(curl_init_rpc() < 0) { LM_ERR("failed to register RPC commands\n"); return -1; } if (init_shmlock() != 0) { LM_CRIT("cannot initialize shmlock.\n"); return -1; } curl_counter_init(); counter_add(connections, curl_connection_count()); if (default_connection_timeout == 0) { LM_ERR("CURL connection timeout set to zero. Using default 4 secs\n"); default_connection_timeout = 4; } if (default_http_proxy_port == 0) { LM_INFO("HTTP proxy port set to 0. Disabling HTTP proxy\n"); } LM_DBG("**** init curl module done. Curl version: %s SSL %s\n", curl_info->version, curl_info->ssl_version); LM_DBG("**** init curl: Number of connection objects: %d \n", curl_connection_count()); LM_DBG("**** init curl: User Agent: %s \n", default_useragent); LM_DBG("**** init curl: HTTPredirect: %d \n", default_http_follow_redirect); LM_DBG("**** init curl: Client Cert: %s Key %s\n", default_tls_clientcert, default_tls_clientkey); LM_DBG("**** init curl: CA Cert: %s \n", default_tls_cacert); LM_DBG("**** init curl: HTTP Proxy: %s Port %d\n", default_http_proxy, default_http_proxy_port); LM_DBG("Extra: Curl supports %s %s %s \n", (curl_info->features & CURL_VERSION_SSL ? "SSL" : ""), (curl_info->features & CURL_VERSION_IPV6 ? "IPv6" : ""), (curl_info->features & CURL_VERSION_IDN ? "IDN" : "") ); return 0; }
int get(const char* url, LPCURL_DOWNLOAD_OBJECT obj, const char* cacert) { LOGI(CURLMGR, "begin get method[%s]", url); LOGI(CURLMGR, "cert path[%s]", cacert); CURL* curl = curl_easy_init(); curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L); curl_easy_setopt(curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0); #ifdef SKIP_PEER_VERIFICATION curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); #endif #ifdef SKIP_HOSTNAME_VERIFICATION curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); #endif curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, &curl_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, obj); // curl_easy_setopt(curl, CURLMOPT_PIPELINING, 1L);//开启多路复用 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1L); curl_easy_setopt(curl, CURLOPT_CAINFO, cacert); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2L); curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2); curl_version_info_data * cvid = curl_version_info(CURLVERSION_NOW); if (cvid->features & CURL_VERSION_SSL) { LOGI(CURLMGR, "SSL support enabled [version %s]", cvid->ssl_version); }else { LOGE(CURLMGR, "no SSL support"); } CURLcode code = curl_easy_perform(curl); if (code != CURLE_OK) { LOGE(CURLMGR, "CURL failed with error code [%d]", code); } else { LOGI(CURLMGR, "CURL success, result[%d]", code); } curl_easy_cleanup(curl); LOGI(CURLMGR, "end get method[%s]", url); return code == CURLE_OK; }
bool cPluginSatip::Start(void) { debug1("%s", __PRETTY_FUNCTION__); // Start any background activities the plugin shall perform. curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); cString info = cString::sprintf("Using CURL %s", data->version); for (int i = 0; data->protocols[i]; ++i) { // Supported protocols: HTTP(S), RTSP, FILE if (startswith(data->protocols[i], "rtsp")) info = cString::sprintf("%s %s", *info, data->protocols[i]); } info("%s", *info); return true; }
/* Determine if this version of curl supports "file://..." &/or "https://..." urls. */ void oc_curl_protocols(struct OCGLOBALSTATE* state) { const char* const* proto; /*weird*/ curl_version_info_data* curldata; curldata = curl_version_info(CURLVERSION_NOW); for(proto=curldata->protocols;*proto;proto++) { if(strcmp("file",*proto)==0) {state->curl.proto_file=1;} if(strcmp("http",*proto)==0) {state->curl.proto_https=1;} } if(ocdebug > 0) { oclog(OCLOGNOTE,"Curl file:// support = %d",state->curl.proto_file); oclog(OCLOGNOTE,"Curl https:// support = %d",state->curl.proto_https); } }
static int check_ssl(void) { int t; curl_version_info_data *data; data = curl_version_info(CURLVERSION_NOW); t = data->features & CURL_VERSION_SSL; if (t) { log_line("curl has SSL support, using https."); } else { log_line("curl lacks SSL support, using http."); } return t; }
void ef_init() { curl_global_init(CURL_GLOBAL_SSL); curl = curl_easy_init(); if ( ! curl ) { fprintf(stderr, "Unable to initiate libcurl !"); exit(1); } curl_version_info_data* info = curl_version_info(CURLVERSION_NOW); char* ua = malloc(15 + strlen(info->version)); sprintf(ua, "libcurl-agent/%s", info->version); curl_easy_setopt(curl, CURLOPT_USERAGENT, ua); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, curl_write_cb); curl_easy_setopt(curl, CURLOPT_CAINFO, EXCITO_CA); free(ua); }
void socketmanager::InitMultiIOHandlerCommon() { LogMsg(LOGT::SOCKTRACE, "socketmanager::InitMultiIOHandlerCommon: START"); st.reset(new sockettimeout(*this)); curlmulti=curl_multi_init(); curl_multi_setopt(curlmulti, CURLMOPT_SOCKETFUNCTION, sock_cb); curl_multi_setopt(curlmulti, CURLMOPT_SOCKETDATA, this); curl_multi_setopt(curlmulti, CURLMOPT_TIMERFUNCTION, multi_timer_cb); curl_multi_setopt(curlmulti, CURLMOPT_TIMERDATA, this); curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); if (!(data->features & CURL_VERSION_ASYNCHDNS)) { LogMsg(LOGT::SOCKTRACE, "This version of libcurl does not support asynchronous DNS resolution, using a workaround."); asyncdns.reset(new adns(this)); } LogMsg(LOGT::SOCKTRACE, "socketmanager::InitMultiIOHandlerCommon: END"); }
void URLLoader::initialize(const char *inCACertFilePath) { #ifdef HX_WINDOWS unsigned int flags = CURL_GLOBAL_WIN32; #else unsigned int flags = 0; #endif curl_global_init(flags | CURL_GLOBAL_SSL); sCACertFile = std::string(inCACertFilePath); #ifdef TRY_GET_FILE get_file_callback = sGetFile; #endif /* Set to 1 to print version information for libcurl. */ if (!sCACertFile.empty()) { FILE *f = fopen(sCACertFile.c_str(),"rb"); bool loaded = f; if (f) fclose(f); ELOG("Open cert file: %s %s\n", sCACertFile.c_str(), loaded ? "Yes" : "NO!!" ); #ifdef IPHONE if (!loaded) { sCACertFile = GetResourcePath() + gAssetBase + inCACertFilePath; FILE *f = fopen(sCACertFile.c_str(),"rb"); loaded = f; if (f) fclose(f); ELOG("Open cert file: %s %s\n", sCACertFile.c_str(), loaded ? "Yes" : "NO!!" ); } #endif } #if 0 curl_version_info_data * info = curl_version_info(CURLVERSION_NOW); ELOG("SSL cert: %s\n", inCACertFilePath); ELOG("libcurl version: %s\n", info->version); ELOG("Support for SSL in libcurl: %d\n", (info->features) & CURL_VERSION_SSL); ELOG("Supported libcurl protocols: "); for (int i=0; info->protocols[i] != 0; i++) { ELOG(" protocol %d: %s",i, info->protocols[i]); } #endif }
mesos_http::mesos_http(mesos& m, const uri& url): m_curl(curl_easy_init()), m_mesos(m), m_url(url), m_connected(true) { if(!m_curl) { throw sinsp_exception("CURL initialization failed."); } curl_version_info_data* data = curl_version_info(CURLVERSION_NOW); if((m_url.get_scheme() == "https") && !(data->features | CURL_VERSION_SSL)) { cleanup(); throw sinsp_exception("HTTPS NOT supported"); } }
CURLcode HTTPRequest:: DoHttpPut() { CURLcode eErrorCode =CURLE_REMOTE_FILE_NOT_FOUND ; CURL *curl; curl = curl_easy_init(); curl_version_info_data * vinfo = curl_version_info( CURLVERSION_NOW ); if(curl != NULL) { struct curl_slist *headers=NULL; SetBaseParam(curl); headers = MakeHeaders(curl); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); //PUT if(_dataLength >0) { curl_easy_setopt(curl, CURLOPT_READDATA, this); curl_easy_setopt(curl, CURLOPT_INFILESIZE, _dataLength); curl_easy_setopt(curl, CURLOPT_READFUNCTION, HTTPRequest::Reader); } else { curl_easy_setopt(curl, CURLOPT_INFILESIZE, 0L); } /* if(_data != NULL && _dataLength > 0) { curl_easy_setopt(curl, CURLOPT_POSTFIELDS, _data); curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, _dataLength); } */ // _responseHeaders.clear(); eErrorCode = curl_easy_perform(curl); long http_code = 0; curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &http_code); statusCode = http_code; curl_slist_free_all(headers); } curl_easy_cleanup(curl); return eErrorCode; }
bool AlexaClientSDKInit::initialize(const std::vector<std::istream*>& jsonStreams) { if (!(curl_version_info(CURLVERSION_NOW)->features & CURL_VERSION_HTTP2)) { ACSDK_ERROR(LX("initializeFailed").d("reason", "curlDoesNotSupportHTTP2")); return false; } if (!utils::configuration::ConfigurationNode::initialize(jsonStreams)) { ACSDK_ERROR(LX("initializeFailed").d("reason", "ConfigurationNode::initializeFailed")); return false; } if (CURLE_OK != curl_global_init(CURL_GLOBAL_ALL)) { ACSDK_ERROR(LX("initializeFailed").d("reason", "curl_global_initFailed")); utils::configuration::ConfigurationNode::uninitialize(); return false; } g_isInitialized++; return true; }
CurlModule::CurlModule() { if (!curl_initialized) { curl_initialized = true; if (curl_global_init(CURL_GLOBAL_ALL)) { ERROR("Initializing libcurl\n"); throw string("Initializing libcurl"); } curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); if (data && data->version >=0) { DBG("using libcurl version '%s'\n", data->version); if (data->features & CURL_VERSION_SSL) { DBG("libcurl with SSL version '%s'\n", data->ssl_version); } else { DBG("libcurl without SSL support\n"); } } } }
extern "C" int32_t GetCurlVersionInfo(int32_t* age, int32_t* supportsSsl, int32_t* supportsAutoDecompression) { curl_version_info_data* versionInfo = curl_version_info(CURLVERSION_NOW); if (!versionInfo || !age || !supportsSsl || !supportsAutoDecompression) { if (age) *age = 0; if (supportsSsl) *supportsSsl = 0; if (supportsAutoDecompression) *supportsAutoDecompression = 0; return 0; } *age = versionInfo->age; *supportsSsl = (versionInfo->features & CURL_VERSION_SSL) == CURL_VERSION_SSL; *supportsAutoDecompression = (versionInfo->features & CURL_VERSION_LIBZ) == CURL_VERSION_LIBZ; return 1; }
static int cert_from_sessioninfo(sxc_client_t *sx, const struct curl_tlssessioninfo *info, CERTCertificate **cert) { if (info->backend != CURLSSLBACKEND_NSS) { curl_version_info_data *data = curl_version_info(CURLVERSION_NOW); sxi_seterr(sx, SXE_ECURL, "SSL backend mismatch: NSS expected, got %d (curl %s)", info->backend, data->ssl_version ? data->ssl_version : "N/A"); return -1; } PRFileDesc *desc = info->internals; if(!desc) { SXDEBUG("NULL PRFileDesc context"); return -EAGAIN; } *cert = SSL_PeerCertificate(desc); if (!*cert) { PRInt32 err = PR_GetError(); SXDEBUG("Unable to retrieve certificate for cluster: %s", PR_ErrorToString(err, PR_LANGUAGE_I_DEFAULT)); return -EAGAIN; } return 0; }
CURLcode HTTPRequest:: DoHttpDelete() { CURLcode eErrorCode =CURLE_REMOTE_FILE_NOT_FOUND ; CURL *curl; curl = curl_easy_init(); curl_version_info_data * vinfo = curl_version_info( CURLVERSION_NOW ); if(curl != NULL) { struct curl_slist *headers=NULL; SetBaseParam(curl); headers = MakeHeaders(curl); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); eErrorCode = curl_easy_perform(curl); long http_code = 0; curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &http_code); statusCode = http_code; curl_slist_free_all(headers); } curl_easy_cleanup(curl); return eErrorCode; }
/** * @brief Gets a user agent string * * @return * A string representation of a user agent */ static std::string get() { // according to the docs for LibCurl, this does not need to be free'd. // http://curl.haxx.se/libcurl/c/curl_version_info.html curl_version_info_data * ver = curl_version_info(CURLVERSION_NOW); std::ostringstream oss; oss << "curl/" << ver->version << '(' << ver->host << ')' << " libcurl " << ver->version << '(' << ver->ssl_version << ')'; if((ver->features & CURL_VERSION_IPV6) == CURL_VERSION_IPV6) { oss << " (ipv6 enabled)"; } return oss.str(); }
static void addUserAgentHeader(xmlrpc_env * const envP, struct curl_slist ** const headerListP, const char * const userAgent) { if (userAgent) { /* Note: Curl has a CURLOPT_USERAGENT option that does some of this work. We prefer to be totally in control, though, so we build the header explicitly. */ curl_version_info_data * const curlInfoP = curl_version_info(CURLVERSION_NOW); char curlVersion[32]; const char * userAgentHeader; snprintf(curlVersion, sizeof(curlVersion), "%u.%u.%u", (curlInfoP->version_num >> 16) && 0xff, (curlInfoP->version_num >> 8) && 0xff, (curlInfoP->version_num >> 0) && 0xff ); xmlrpc_asprintf(&userAgentHeader, "User-Agent: %s Xmlrpc-c/%s Curl/%s", userAgent, XMLRPC_C_VERSION, curlVersion); if (userAgentHeader == xmlrpc_strsol) xmlrpc_faultf(envP, "Couldn't allocate memory for " "User-Agent header"); else { addHeader(envP, headerListP, userAgentHeader); xmlrpc_strfree(userAgentHeader); } } }
/* * call-seq: * Curl.gssnegotiate? => true or false * * Returns true if the installed libcurl supports HTTP GSS-Negotiate. * For libcurl versions < 7.10.6, always returns false. */ static VALUE ruby_curl_gssnegotiate_q(VALUE mod) { #ifdef HAVE_CURL_VERSION_GSSNEGOTIATE curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW); return((ver->features & CURL_VERSION_GSSNEGOTIATE) ? Qtrue : Qfalse); #else return Qfalse; #endif }