summaryrefslogtreecommitdiff
path: root/src/raptor_www_curl.c
diff options
context:
space:
mode:
authorDave Beckett <dave@dajobe.org>2003-03-18 01:21:20 +0000
committerDave Beckett <dave@dajobe.org>2003-03-18 01:21:20 +0000
commitc1018a7a3b2719819a9df58cbff6e4dd362c40a2 (patch)
tree61b1da6272f790af0eb56cbd7f148b5365c35739 /src/raptor_www_curl.c
parent630165cc06aea089b0f643aee25a0e0c6e80ca6e (diff)
downloadraptor-c1018a7a3b2719819a9df58cbff6e4dd362c40a2.tar.gz
Handle www->failed and aborting transfer.
(raptor_www_curl_init): Use passed-in connection if available.
Diffstat (limited to 'src/raptor_www_curl.c')
-rw-r--r--src/raptor_www_curl.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/raptor_www_curl.c b/src/raptor_www_curl.c
index 8fa7f88f..94d93ebd 100644
--- a/src/raptor_www_curl.c
+++ b/src/raptor_www_curl.c
@@ -42,6 +42,12 @@ raptor_www_curl_write_callback(void *ptr, size_t size, size_t nmemb, void *userd
{
raptor_www* www=(raptor_www*)userdata;
int bytes=size*nmemb;
+
+ /* If WWW has been aborted, return nothing so that
+ * libcurl will abort the transfer
+ */
+ if(www->failed)
+ return -1;
if(www->write_bytes)
www->write_bytes(www, www->write_bytes_userdata, ptr, size, nmemb);
@@ -56,6 +62,12 @@ raptor_www_curl_header_callback(void *ptr, size_t size, size_t nmemb, void *u
raptor_www* www=(raptor_www*)userdata;
int bytes=size*nmemb;
+ /* If WWW has been aborted, return nothing so that
+ * libcurl will abort the transfer
+ */
+ if(www->failed)
+ return -1;
+
if(!strncmp(ptr, "Content-Type: ", 14)) {
int len=bytes-16;
char *type_buffer=(char*)malloc(len+1);
@@ -73,9 +85,8 @@ raptor_www_curl_header_callback(void *ptr, size_t size, size_t nmemb, void *u
void
raptor_www_curl_init(raptor_www *www)
{
- www->status=curl_global_init(CURL_GLOBAL_ALL);
-
- www->curl_handle=curl_easy_init();
+ if(!www->curl_handle)
+ www->curl_handle=curl_easy_init();
/* send all data to this function */
curl_easy_setopt(www->curl_handle, CURLOPT_WRITEFUNCTION,