diff options
author | David Shaw <dshaw@jabberwocky.com> | 2009-05-28 18:20:49 +0200 |
---|---|---|
committer | David Shaw <dshaw@jabberwocky.com> | 2009-05-28 18:20:49 +0200 |
commit | bcf540f2d05be031fc16d9faf572a75c65834f12 (patch) | |
tree | 93ae0636c57de16e0d91d24c9c0c63e79d3c1fd1 /common | |
parent | * http.h, http.c (send_request): Pass in srvtag and make its presence (diff) | |
download | gnupg2-bcf540f2d05be031fc16d9faf572a75c65834f12.tar.xz gnupg2-bcf540f2d05be031fc16d9faf572a75c65834f12.zip |
Avoid caches to get the most recent copy of the key. This is bug #1061
Diffstat (limited to 'common')
-rw-r--r-- | common/ChangeLog | 7 | ||||
-rw-r--r-- | common/http.c | 39 | ||||
-rw-r--r-- | common/http.h | 6 |
3 files changed, 43 insertions, 9 deletions
diff --git a/common/ChangeLog b/common/ChangeLog index a03105a15..2f5a65a03 100644 --- a/common/ChangeLog +++ b/common/ChangeLog @@ -1,3 +1,10 @@ +2009-05-28 David Shaw <dshaw@jabberwocky.com> + + From 1.4: + + * http.h, http.c (send_request) Pass in a STRLIST for additional + headers. Change all callers. + 2009-05-27 David Shaw <dshaw@jabberwocky.com> From 1.4: diff --git a/common/http.c b/common/http.c index 4999ce7d1..c12bd2b3e 100644 --- a/common/http.c +++ b/common/http.c @@ -128,8 +128,8 @@ static int remove_escapes (char *string); static int insert_escapes (char *buffer, const char *string, const char *special); static uri_tuple_t parse_tuple (char *string); -static gpg_error_t send_request (http_t hd, const char *auth, - const char *proxy, const char *srvtag); +static gpg_error_t send_request (http_t hd, const char *auth,const char *proxy, + const char *srvtag,strlist_t headers); static char *build_rel_path (parsed_uri_t uri); static gpg_error_t parse_response (http_t hd); @@ -317,7 +317,7 @@ http_register_tls_callback ( gpg_error_t (*cb) (http_t, void *, int) ) gpg_error_t http_open (http_t *r_hd, http_req_t reqtype, const char *url, const char *auth, unsigned int flags, const char *proxy, - void *tls_context, const char *srvtag) + void *tls_context, const char *srvtag,strlist_t headers) { gpg_error_t err; http_t hd; @@ -338,7 +338,7 @@ http_open (http_t *r_hd, http_req_t reqtype, const char *url, err = http_parse_uri (&hd->uri, url); if (!err) - err = send_request (hd, auth, proxy, srvtag); + err = send_request (hd, auth, proxy, srvtag, headers); if (err) { @@ -457,12 +457,12 @@ http_wait_response (http_t hd) gpg_error_t http_open_document (http_t *r_hd, const char *document, const char *auth, unsigned int flags, const char *proxy, - void *tls_context, const char *srvtag) + void *tls_context, const char *srvtag,strlist_t headers) { gpg_error_t err; err = http_open (r_hd, HTTP_REQ_GET, document, auth, flags, - proxy, tls_context, srvtag); + proxy, tls_context, srvtag, headers); if (err) return err; @@ -835,7 +835,8 @@ parse_tuple (char *string) * Returns 0 if the request was successful */ static gpg_error_t -send_request (http_t hd, const char *auth, const char *proxy,const char *srvtag) +send_request (http_t hd, const char *auth, + const char *proxy,const char *srvtag,strlist_t headers) { gnutls_session_t tls_session; gpg_error_t err; @@ -1051,6 +1052,17 @@ send_request (http_t hd, const char *auth, const char *proxy,const char *srvtag) err = gpg_error_from_syserror (); else err = 0; + + if(err==0) + for(;headers;headers=headers->next) + { + if ((es_fputs (headers->d, hd->fp_write) || es_fflush (hd->fp_write)) + || (es_fputs("\r\n",hd->fp_write) || es_fflush(hd->fp_write))) + { + err = gpg_error_from_syserror (); + break; + } + } } leave: @@ -1060,12 +1072,25 @@ send_request (http_t hd, const char *auth, const char *proxy,const char *srvtag) function and only then assign a stdio stream. This allows for better error reporting that through standard stdio means. */ err = write_server (hd->sock, request, strlen (request)); + + if(err==0) + for(;headers;headers=headers->next) + { + err = write_server( hd->sock, headers->d, strlen(headers->d) ); + if(err) + break; + err = write_server( hd->sock, "\r\n", 2 ); + if(err) + break; + } + if (!err) { hd->fp_write = fdopen (hd->sock, "w"); if (!hd->fp_write) err = gpg_error_from_syserror (); } + #endif /*!HTTP_USE_ESTREAM*/ xfree (request); diff --git a/common/http.h b/common/http.h index 3b049a7f2..28a5304eb 100644 --- a/common/http.h +++ b/common/http.h @@ -82,7 +82,8 @@ gpg_error_t http_open (http_t *r_hd, http_req_t reqtype, unsigned int flags, const char *proxy, void *tls_context, - const char *srvtag); + const char *srvtag, + strlist_t headers); void http_start_data (http_t hd); @@ -96,7 +97,8 @@ gpg_error_t http_open_document (http_t *r_hd, unsigned int flags, const char *proxy, void *tls_context, - const char *srvtag); + const char *srvtag, + strlist_t headers); #ifdef HTTP_USE_ESTREAM estream_t http_get_read_ptr (http_t hd); |