From 7808e4a763692b8bcd95264d39caf85fad32f0bd Mon Sep 17 00:00:00 2001 From: David Shaw Date: Sat, 2 Mar 2013 20:07:27 -0500 Subject: [PATCH] Emulate curl_easy_getinfo and CURLINFO_RESPONSE_CODE in curl-shim. * keyserver/curl-shim.h, keyserver/curl-shim.c (curl_easy_getinfo): New. Return the HTTP status code for the last transfer. --- keyserver/curl-shim.c | 25 +++++++++++++++++++++++-- keyserver/curl-shim.h | 9 ++++++++- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/keyserver/curl-shim.c b/keyserver/curl-shim.c index 136436a10..be8778096 100644 --- a/keyserver/curl-shim.c +++ b/keyserver/curl-shim.c @@ -1,8 +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, - * 2012 Free Software Foundation, Inc. + * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2012, + * 2013 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -307,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" \ diff --git a/keyserver/curl-shim.h b/keyserver/curl-shim.h index e37d81675..df28fcc9c 100644 --- a/keyserver/curl-shim.h +++ b/keyserver/curl-shim.h @@ -1,5 +1,6 @@ /* curl-shim.h - * Copyright (C) 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. + * Copyright (C) 2005, 2006, 2007, 2008, 2009, + * 2013 Free Software Foundation, Inc. * * This file is part of GNUPG. * @@ -54,6 +55,11 @@ typedef enum CURLOPT_SRVTAG_GPG_HACK } CURLoption; +typedef enum + { + CURLINFO_RESPONSE_CODE + } CURLINFO; + typedef size_t (*write_func)(char *buffer,size_t size, size_t nitems,void *outstream); @@ -93,6 +99,7 @@ void curl_global_cleanup(void); CURL *curl_easy_init(void); CURLcode curl_easy_setopt(CURL *curl,CURLoption option,...); CURLcode curl_easy_perform(CURL *curl); +CURLcode curl_easy_getinfo(CURL *curl, CURLINFO info, ... ); void curl_easy_cleanup(CURL *curl); char *curl_escape(char *str,int len); #define curl_free(x) free(x)