diff options
author | Werner Koch <wk@gnupg.org> | 2006-08-16 12:47:53 +0200 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2006-08-16 12:47:53 +0200 |
commit | b744f963d7061ce55d2eed65b281298476e54fb7 (patch) | |
tree | 6e8ccb3c39a45c16b4ca6cdb2273eb3b8bc2a888 /keyserver/curl-shim.c | |
parent | Changed HTTP API. (diff) | |
download | gnupg2-b744f963d7061ce55d2eed65b281298476e54fb7.tar.xz gnupg2-b744f963d7061ce55d2eed65b281298476e54fb7.zip |
With --enable-gpg the keyservers are now build and a first test using gpg2
shows no prblems. Needs more testing of course.
Diffstat (limited to 'keyserver/curl-shim.c')
-rw-r--r-- | keyserver/curl-shim.c | 73 |
1 files changed, 43 insertions, 30 deletions
diff --git a/keyserver/curl-shim.c b/keyserver/curl-shim.c index c71c655b5..12c7afa94 100644 --- a/keyserver/curl-shim.c +++ b/keyserver/curl-shim.c @@ -27,6 +27,7 @@ #include <string.h> #include <stdio.h> #include <errno.h> + #include "http.h" #include "util.h" #include "ksutil.h" @@ -100,7 +101,11 @@ curl_easy_init(void) void curl_easy_cleanup(CURL *curl) { - free(curl); + if (curl) + { + http_close (curl->hd); + free(curl); + } } CURLcode @@ -177,42 +182,46 @@ curl_easy_perform(CURL *curl) if(curl->flags.post) { - rc=http_open(&curl->hd,HTTP_REQ_POST,curl->url,curl->auth,0,proxy); - if(rc==0) + rc = http_open (&curl->hd, HTTP_REQ_POST, curl->url, curl->auth, + 0, proxy, NULL); + if (!rc) { - char content_len[50]; - unsigned int post_len=strlen(curl->postfields); - - iobuf_writestr(curl->hd.fp_write, - "Content-Type: application/x-www-form-urlencoded\r\n"); - sprintf(content_len,"Content-Length: %u\r\n",post_len); - - iobuf_writestr(curl->hd.fp_write,content_len); - - http_start_data(&curl->hd); - iobuf_write(curl->hd.fp_write,curl->postfields,post_len); - rc=http_wait_response(&curl->hd,&curl->status); - if(rc==0 && curl->flags.failonerror && curl->status>=300) - err=CURLE_HTTP_RETURNED_ERROR; + unsigned int post_len = strlen(curl->postfields); + + es_fprintf (http_get_write_ptr (curl->hd), + "Content-Type: application/x-www-form-urlencoded\r\n" + "Content-Length: %u\r\n", post_len); + http_start_data (curl->hd); + es_write (http_get_write_ptr (curl->hd), + curl->postfields, post_len, NULL); + + rc = http_wait_response (curl->hd); + curl->status = http_get_status_code (curl->hd); + if (!rc && curl->flags.failonerror && curl->status>=300) + err = CURLE_HTTP_RETURNED_ERROR; + http_close(curl->hd); + curl->hd = NULL; } } else { - rc=http_open(&curl->hd,HTTP_REQ_GET,curl->url,curl->auth,0,proxy); - if(rc==0) + rc = http_open (&curl->hd, HTTP_REQ_GET, curl->url, curl->auth, + 0, proxy, NULL); + if (!rc) { - rc=http_wait_response(&curl->hd,&curl->status); - if(rc==0) + rc = http_wait_response (curl->hd); + curl->status = http_get_status_code (curl->hd); + if (!rc) { - if(curl->flags.failonerror && curl->status>=300) - err=CURLE_HTTP_RETURNED_ERROR; + if (curl->flags.failonerror && curl->status>=300) + err = CURLE_HTTP_RETURNED_ERROR; else { - unsigned int maxlen=1024,buflen,len; - byte *line=NULL; + unsigned int maxlen = 1024, buflen, len; + unsigned char *line = NULL; - while((len=iobuf_read_line(curl->hd.fp_read, - &line,&buflen,&maxlen))) + while ((len = es_read_line (http_get_read_ptr (curl->hd), + &line, &buflen, &maxlen))) { size_t ret; @@ -226,12 +235,16 @@ curl_easy_perform(CURL *curl) } } - xfree(line); - http_close(&curl->hd); + es_free (line); + http_close(curl->hd); + curl->hd = NULL; } } else - http_close(&curl->hd); + { + http_close (curl->hd); + curl->hd = NULL; + } } } |