--- old/src/http_client.c	Fri Oct 13 17:05:56 2006
+++ src/http_client.c	Sun Oct 28 15:31:39 2007
@@ -17,6 +17,77 @@
 
 extern OCSPD_CONFIG *ocspd_conf;
 
+#ifdef USE_CURL
+
+#include "libcurl/curl.h"
+
+size_t ocspd_http_write_func( void *ptr, size_t size, size_t nmemb, void *stream) {
+
+    BUF_MEM * buf = (BUF_MEM *)stream;
+    size_t length = size*nmemb;
+
+    if ((length == 0) || (buf == NULL) || (!BUF_MEM_grow(buf, buf->length + length)))
+        return 0;
+
+    memcpy(buf->data, ptr, length);
+    return length;
+}
+
+
+BUF_MEM *ocspd_http_get ( URL *url, unsigned long max_size ) {
+
+    CURLcode rc;
+    BUF_MEM *buf = NULL;
+
+    buf = BUF_MEM_new();
+
+    char url_str[1024];
+    sprintf(url_str, "%s://%s:%d/%s", (url->proto == OCSP_CRL_PROTO_HTTP) ? "http" : "https" ,url->addr, url->port, url->path);
+
+    CURL * handle = curl_easy_init(); 
+
+    curl_easy_setopt(handle, CURLOPT_URL, url_str);
+    curl_easy_setopt(handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
+    curl_easy_setopt(handle, CURLOPT_SSL_VERIFYPEER, 0);
+    curl_easy_setopt(handle, CURLOPT_SSL_VERIFYHOST, 0); 
+    curl_easy_setopt(handle, CURLOPT_HEADERFUNCTION, ocspd_http_write_func);
+    curl_easy_setopt(handle, CURLOPT_HEADERDATA, buf);  
+    curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, ocspd_http_write_func);
+    curl_easy_setopt(handle, CURLOPT_WRITEDATA, buf);  
+    curl_easy_setopt(handle, CURLOPT_TIMEOUT, ocspd_conf->http_transfer_timeout);
+    curl_easy_setopt(handle, CURLOPT_CONNECTTIMEOUT, ocspd_conf->http_connect_timeout);
+    curl_easy_setopt(handle, CURLOPT_FAILONERROR,1); 
+    if ((url->usr != NULL) && (url->pwd != NULL))
+    {
+        char userpwd_str[1024];
+        sprintf(userpwd_str, "%s:%s", url->usr, url->pwd);
+        curl_easy_setopt(handle, CURLOPT_USERPWD,userpwd_str); 
+    }
+
+    rc = curl_easy_perform(handle);
+
+    if (rc != CURLE_OK)
+    {
+        syslog( LOG_ERR, 
+            "ERROR::HTTP::Read failed "
+            " [ %s ]", curl_easy_strerror(rc) );
+        BUF_MEM_free( buf );
+        return NULL;
+    }
+
+    curl_easy_cleanup(handle);
+
+    return buf;
+}
+
+
+int ocspd_parse_http_headers ( BIO *in ) {
+    return 1;
+}
+
+
+#else
+
 /* Functions */
 BIO *ocspd_http_connect( URL *url ) {
 
@@ -154,4 +225,7 @@
 	return 1;
 
 }
+
+#endif
+
 
