diff options
author | Kévin THIERRY <kevin.thierry@open.eurogiciel.org> | 2014-11-13 09:26:18 +0100 |
---|---|---|
committer | Kévin THIERRY <kevin.thierry@open.eurogiciel.org> | 2014-11-13 09:26:18 +0100 |
commit | e87a22655de485af790db1d4c51f4bc166a2bbd6 (patch) | |
tree | 93d088c2bc13d9a26e6f24b70936d998bd1404df /keyserver/curl-shim.c | |
parent | 6576640b55777bd811a12a188b9b1f3c63653799 (diff) | |
download | gpg2-e87a22655de485af790db1d4c51f4bc166a2bbd6.tar.gz gpg2-e87a22655de485af790db1d4c51f4bc166a2bbd6.tar.bz2 gpg2-e87a22655de485af790db1d4c51f4bc166a2bbd6.zip |
Imported Upstream version 2.0.26upstream/2.0.26
Diffstat (limited to 'keyserver/curl-shim.c')
-rw-r--r-- | keyserver/curl-shim.c | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/keyserver/curl-shim.c b/keyserver/curl-shim.c index 500d9f5..be87780 100644 --- a/keyserver/curl-shim.c +++ b/keyserver/curl-shim.c @@ -1,7 +1,8 @@ /* curl-shim.c - Implement a small subset of the curl API in terms of * the iobuf HTTP API * - * Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. + * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2012, + * 2013 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -174,6 +175,9 @@ curl_easy_perform(CURL *curl) CURLcode err=CURLE_OK; const char *errstr=NULL; char *proxy=NULL; + struct http_srv srv; + + memset(&srv,0,sizeof(srv)); /* Emulate the libcurl proxy behavior. If the calling program set a proxy, use it. If it didn't set a proxy or set it to NULL, check @@ -186,10 +190,17 @@ curl_easy_perform(CURL *curl) else proxy=getenv(HTTP_PROXY_ENV); + if(curl->srvtag) + srv.srvtag=curl->srvtag; + if(curl->flags.verbose) { fprintf(curl->errors,"* HTTP proxy is \"%s\"\n",proxy?proxy:"null"); fprintf(curl->errors,"* HTTP URL is \"%s\"\n",curl->url); + if(srv.srvtag) + fprintf(curl->errors, + "* SRV tag is \"%s\": host and port may be overridden\n", + srv.srvtag); fprintf(curl->errors,"* HTTP auth is \"%s\"\n", curl->auth?curl->auth:"null"); fprintf(curl->errors,"* HTTP method is %s\n", @@ -199,12 +210,16 @@ curl_easy_perform(CURL *curl) if(curl->flags.post) { rc = http_open (&curl->hd, HTTP_REQ_POST, curl->url, curl->auth, - 0, proxy, NULL, curl->srvtag, + 0, proxy, NULL, &srv, curl->headers?curl->headers->list:NULL); if (!rc) { unsigned int post_len = strlen(curl->postfields); + if(curl->flags.verbose && srv.used_server && srv.used_port) + fprintf (curl->errors, "* HTTP host:port post-SRV is \"%s:%hu\"\n", + srv.used_server, srv.used_port); + es_fprintf (http_get_write_ptr (curl->hd), "Content-Type: application/x-www-form-urlencoded\r\n" "Content-Length: %u\r\n", post_len); @@ -223,10 +238,14 @@ curl_easy_perform(CURL *curl) else { rc = http_open (&curl->hd, HTTP_REQ_GET, curl->url, curl->auth, - 0, proxy, NULL, curl->srvtag, + 0, proxy, NULL, &srv, curl->headers?curl->headers->list:NULL); if (!rc) { + if(curl->flags.verbose && srv.used_server && srv.used_port) + fprintf (curl->errors, "* HTTP host:port post-SRV is \"%s:%hu\"\n", + srv.used_server, srv.used_port); + rc = http_wait_response (curl->hd); curl->status = http_get_status_code (curl->hd); if (!rc) @@ -268,6 +287,8 @@ curl_easy_perform(CURL *curl) } } + xfree(srv.used_server); + switch(gpg_err_code (rc)) { case 0: @@ -286,6 +307,27 @@ curl_easy_perform(CURL *curl) return handle_error(curl,err,errstr); } +CURLcode +curl_easy_getinfo(CURL *curl, CURLINFO info, ... ) +{ + va_list ap; + long *var; + + va_start(ap,info); + + switch(info) + { + case CURLINFO_RESPONSE_CODE: + var=va_arg(ap,long *); + *var=curl->status; + break; + default: + break; + } + + return handle_error(curl,CURLE_OK,NULL); +} + /* This is not the same exact set that is allowed according to RFC-2396, but it is what the real curl uses. */ #define VALID_URI_CHARS "abcdefghijklmnopqrstuvwxyz" \ |