summaryrefslogtreecommitdiff
path: root/keyserver/curl-shim.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyserver/curl-shim.c')
-rw-r--r--keyserver/curl-shim.c48
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" \