From ca0b94d4d41c81045ed97fad0569ff4b64e5a6fe 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 | 24 +++++++++++++++++++++++- keyserver/curl-shim.h | 9 ++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/keyserver/curl-shim.c b/keyserver/curl-shim.c index 857b5c184..ce510cb2b 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, 2012 Free Software Foundation, Inc. + * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2012, + * 2013 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -291,6 +292,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 0d378e834..a8609dffc 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. * @@ -53,6 +54,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); @@ -92,6 +98,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_easy_escape(CURL *curl,char *str,int len); #define curl_free(x) free(x)