aboutsummaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2010-07-16 13:19:45 +0000
committerWerner Koch <[email protected]>2010-07-16 13:19:45 +0000
commit8b8925a2bdbb12dd537dde20a27cdb1416c2f1ae (patch)
tree366acb6bb52e61242bb39682ddddb76615c3ba34 /common
parentMake it build on W32 again. (diff)
downloadgnupg-8b8925a2bdbb12dd537dde20a27cdb1416c2f1ae.tar.gz
gnupg-8b8925a2bdbb12dd537dde20a27cdb1416c2f1ae.zip
Some work on porting dirmngr (unfinished)
Ported gpgtar to W32.
Diffstat (limited to 'common')
-rw-r--r--common/ChangeLog29
-rw-r--r--common/b64enc.c146
-rw-r--r--common/estream.c16
-rw-r--r--common/http.c173
-rw-r--r--common/http.h10
-rw-r--r--common/util.h6
6 files changed, 261 insertions, 119 deletions
diff --git a/common/ChangeLog b/common/ChangeLog
index dd8c0a3a2..ae928ad9b 100644
--- a/common/ChangeLog
+++ b/common/ChangeLog
@@ -1,3 +1,32 @@
+2010-07-16 Werner Koch <[email protected]>
+
+ * http.h (HTTP_FLAG_IGNORE_CL): Add flag .
+ * http.c (WITHOUT_GNU_PTH): Test macro for Pth support.
+ (http_parse_uri): s/xcalloc/xtrycalloc/.
+ (send_request): Replace of discrete allocation and sprintf by
+ xtryasprintf.
+ (http_wait_response): Replace HTTP_FLAG_NO_SHUTDOWN by
+ HTTP_FLAG_SHUTDOWN to change the default to no shutdown.
+ (cookie_read) [HAVE_PTH]: Use pth_read.
+ (longcounter_t): New.
+ (struct cookie_s): Add support for content length. Turn flag
+ fields into bit types.
+ (parse_response): Parse content length header.
+ (cookie_read): Take care of the content length.
+
+2010-07-08 Werner Koch <[email protected]>
+
+ * estream.c (estream_functions_file): Remove and replace by
+ identical estream_functions_fd.
+
+2010-07-06 Werner Koch <[email protected]>
+
+ * util.h (b64state): Add field STREAM.
+ * b64enc.c (b64enc_start): Factor code out to ..
+ (enc_start): new.
+ (b64enc_start_es, my_fputs): New.
+ (b64enc_write, b64enc_finish): Support estream.
+
2010-06-24 Werner Koch <[email protected]>
* asshelp.c (lock_agent_spawning) [W32]: Use CreateMutexW.
diff --git a/common/b64enc.c b/common/b64enc.c
index 4722bd1e1..1e277f4cb 100644
--- a/common/b64enc.c
+++ b/common/b64enc.c
@@ -1,5 +1,5 @@
/* b64enc.c - Simple Base64 encoder.
- * Copyright (C) 2001, 2003, 2004, 2008 Free Software Foundation, Inc.
+ * Copyright (C) 2001, 2003, 2004, 2008, 2010 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -136,20 +136,13 @@ static const u32 crc_table[256] = {
};
-/* Prepare for base-64 writing to the stream FP. If TITLE is not NULL
- and not an empty string, this string will be used as the title for
- the armor lines, with TITLE being an empty string, we don't write
- the header lines and furthermore even don't write any linefeeds.
- If TITLE starts with "PGP " the OpenPGP CRC checksum will be
- written as well. With TITLE beeing NULL, we merely don't write
- header but make sure that lines are not too long. Note, that we
- don't write any output unless at least one byte get written using
- b64enc_write. */
-gpg_error_t
-b64enc_start (struct b64state *state, FILE *fp, const char *title)
+static gpg_error_t
+enc_start (struct b64state *state, FILE *fp, estream_t stream,
+ const char *title)
{
memset (state, 0, sizeof *state);
state->fp = fp;
+ state->stream = stream;
if (title && !*title)
state->flags |= B64ENC_NO_LINEFEEDS;
else if (title)
@@ -167,6 +160,39 @@ b64enc_start (struct b64state *state, FILE *fp, const char *title)
}
+/* Prepare for base-64 writing to the stream FP. If TITLE is not NULL
+ and not an empty string, this string will be used as the title for
+ the armor lines, with TITLE being an empty string, we don't write
+ the header lines and furthermore even don't write any linefeeds.
+ If TITLE starts with "PGP " the OpenPGP CRC checksum will be
+ written as well. With TITLE beeing NULL, we merely don't write
+ header but make sure that lines are not too long. Note, that we
+ don't write any output unless at least one byte get written using
+ b64enc_write. */
+gpg_error_t
+b64enc_start (struct b64state *state, FILE *fp, const char *title)
+{
+ return enc_start (state, fp, NULL, title);
+}
+
+/* Same as b64enc_start but takes an estream. */
+gpg_error_t
+b64enc_start_es (struct b64state *state, estream_t fp, const char *title)
+{
+ return enc_start (state, NULL, fp, title);
+}
+
+
+static int
+my_fputs (const char *string, struct b64state *state)
+{
+ if (state->stream)
+ return es_fputs (string, state->stream);
+ else
+ return fputs (string, state->fp);
+}
+
+
/* Write NBYTES from BUFFER to the Base 64 stream identified by
STATE. With BUFFER and NBYTES being 0, merely do a fflush on the
stream. */
@@ -176,13 +202,13 @@ b64enc_write (struct b64state *state, const void *buffer, size_t nbytes)
unsigned char radbuf[4];
int idx, quad_count;
const unsigned char *p;
- FILE *fp = state->fp;
if (!nbytes)
{
- if (buffer && fflush (fp))
- goto write_error;
+ if (buffer)
+ if (state->stream? es_fflush (state->stream) : fflush (state->fp))
+ goto write_error;
return 0;
}
@@ -190,12 +216,12 @@ b64enc_write (struct b64state *state, const void *buffer, size_t nbytes)
{
if (state->title)
{
- if ( fputs ("-----BEGIN ", fp) == EOF
- || fputs (state->title, fp) == EOF
- || fputs ("-----\n", fp) == EOF)
+ if ( my_fputs ("-----BEGIN ", state) == EOF
+ || my_fputs (state->title, state) == EOF
+ || my_fputs ("-----\n", state) == EOF)
goto write_error;
if ( (state->flags & B64ENC_USE_PGPCRC)
- && fputs ("\n", fp) == EOF)
+ && my_fputs ("\n", state) == EOF)
goto write_error;
}
@@ -228,16 +254,27 @@ b64enc_write (struct b64state *state, const void *buffer, size_t nbytes)
tmp[1] = bintoasc[(((*radbuf<<4)&060)|((radbuf[1] >> 4)&017))&077];
tmp[2] = bintoasc[(((radbuf[1]<<2)&074)|((radbuf[2]>>6)&03))&077];
tmp[3] = bintoasc[radbuf[2]&077];
- for (idx=0; idx < 4; idx++)
- putc (tmp[idx], fp);
- idx = 0;
- if (ferror (fp))
- goto write_error;
+ if (state->stream)
+ {
+ for (idx=0; idx < 4; idx++)
+ es_putc (tmp[idx], state->stream);
+ idx = 0;
+ if (es_ferror (state->stream))
+ goto write_error;
+ }
+ else
+ {
+ for (idx=0; idx < 4; idx++)
+ putc (tmp[idx], state->fp);
+ idx = 0;
+ if (ferror (state->fp))
+ goto write_error;
+ }
if (++quad_count >= (64/4))
{
quad_count = 0;
if (!(state->flags & B64ENC_NO_LINEFEEDS)
- && fputs ("\n", fp) == EOF)
+ && my_fputs ("\n", state) == EOF)
goto write_error;
}
}
@@ -251,20 +288,19 @@ b64enc_write (struct b64state *state, const void *buffer, size_t nbytes)
return gpg_error_from_syserror ();
}
+
gpg_error_t
b64enc_finish (struct b64state *state)
{
gpg_error_t err = 0;
unsigned char radbuf[4];
int idx, quad_count;
- FILE *fp;
char tmp[4];
if (!(state->flags & B64ENC_DID_HEADER))
goto cleanup;
/* Flush the base64 encoding */
- fp = state->fp;
idx = state->idx;
quad_count = state->quad_count;
assert (idx < 4);
@@ -285,17 +321,28 @@ b64enc_finish (struct b64state *state)
tmp[2] = bintoasc[((radbuf[1] << 2) & 074) & 077];
tmp[3] = '=';
}
- for (idx=0; idx < 4; idx++)
- putc (tmp[idx], fp);
- idx = 0;
- if (ferror (fp))
- goto write_error;
-
+ if (state->stream)
+ {
+ for (idx=0; idx < 4; idx++)
+ es_putc (tmp[idx], state->stream);
+ idx = 0;
+ if (es_ferror (state->stream))
+ goto write_error;
+ }
+ else
+ {
+ for (idx=0; idx < 4; idx++)
+ putc (tmp[idx], state->fp);
+ idx = 0;
+ if (ferror (state->fp))
+ goto write_error;
+ }
+
if (++quad_count >= (64/4))
{
quad_count = 0;
if (!(state->flags & B64ENC_NO_LINEFEEDS)
- && fputs ("\n", fp) == EOF)
+ && my_fputs ("\n", state) == EOF)
goto write_error;
}
}
@@ -303,13 +350,13 @@ b64enc_finish (struct b64state *state)
/* Finish the last line and write the trailer. */
if (quad_count
&& !(state->flags & B64ENC_NO_LINEFEEDS)
- && fputs ("\n", fp) == EOF)
+ && my_fputs ("\n", state) == EOF)
goto write_error;
if ( (state->flags & B64ENC_USE_PGPCRC) )
{
/* Write the CRC. */
- putc ('=', fp);
+ my_fputs ("=", state);
radbuf[0] = state->crc >>16;
radbuf[1] = state->crc >> 8;
radbuf[2] = state->crc;
@@ -317,20 +364,30 @@ b64enc_finish (struct b64state *state)
tmp[1] = bintoasc[(((*radbuf<<4)&060)|((radbuf[1]>>4)&017))&077];
tmp[2] = bintoasc[(((radbuf[1]<<2)&074)|((radbuf[2]>>6)&03))&077];
tmp[3] = bintoasc[radbuf[2]&077];
- for (idx=0; idx < 4; idx++)
- putc (tmp[idx], fp);
- if (ferror (fp))
- goto write_error;
+ if (state->stream)
+ {
+ for (idx=0; idx < 4; idx++)
+ es_putc (tmp[idx], state->stream);
+ if (es_ferror (state->stream))
+ goto write_error;
+ }
+ else
+ {
+ for (idx=0; idx < 4; idx++)
+ putc (tmp[idx], state->fp);
+ if (ferror (state->fp))
+ goto write_error;
+ }
if (!(state->flags & B64ENC_NO_LINEFEEDS)
- && fputs ("\n", fp) == EOF)
+ && my_fputs ("\n", state) == EOF)
goto write_error;
}
if (state->title)
{
- if ( fputs ("-----END ", fp) == EOF
- || fputs (state->title, fp) == EOF
- || fputs ("-----\n", fp) == EOF)
+ if ( my_fputs ("-----END ", state) == EOF
+ || my_fputs (state->title, state) == EOF
+ || my_fputs ("-----\n", state) == EOF)
goto write_error;
}
@@ -346,6 +403,7 @@ b64enc_finish (struct b64state *state)
state->title = NULL;
}
state->fp = NULL;
+ state->stream = NULL;
return err;
}
diff --git a/common/estream.c b/common/estream.c
index bf7955d06..3ab68b5ff 100644
--- a/common/estream.c
+++ b/common/estream.c
@@ -994,7 +994,7 @@ es_func_fp_seek (void *cookie, off_t *offset, int whence)
return 0;
}
-/* Destroy function for fd objects. */
+/* Destroy function for FILE* objects. */
static int
es_func_fp_destroy (void *cookie)
{
@@ -1076,14 +1076,6 @@ es_func_file_create (void **cookie, int *filedes,
return err;
}
-static es_cookie_io_functions_t estream_functions_file =
- {
- es_func_fd_read,
- es_func_fd_write,
- es_func_fd_seek,
- es_func_fd_destroy
- };
-
static int
es_convert_mode (const char *mode, unsigned int *modeflags)
@@ -2197,7 +2189,7 @@ es_fopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode)
goto out;
create_called = 1;
- err = es_create (&stream, cookie, fd, estream_functions_file, modeflags, 0);
+ err = es_create (&stream, cookie, fd, estream_functions_fd, modeflags, 0);
if (err)
goto out;
@@ -2207,7 +2199,7 @@ es_fopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode)
out:
if (err && create_called)
- (*estream_functions_file.func_close) (cookie);
+ (*estream_functions_fd.func_close) (cookie);
return stream;
}
@@ -2519,7 +2511,7 @@ es_freopen (const char *ES__RESTRICT path, const char *ES__RESTRICT mode,
goto leave;
create_called = 1;
- es_initialize (stream, cookie, fd, estream_functions_file, modeflags);
+ es_initialize (stream, cookie, fd, estream_functions_fd, modeflags);
leave:
diff --git a/common/http.c b/common/http.c
index bb39768e4..ab159e28e 100644
--- a/common/http.c
+++ b/common/http.c
@@ -1,6 +1,6 @@
/* http.c - HTTP protocol handler
* Copyright (C) 1999, 2001, 2002, 2003, 2004, 2006,
- * 2009 Free Software Foundation, Inc.
+ * 2009, 2010 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -57,6 +57,16 @@
# include <netdb.h>
#endif /*!HAVE_W32_SYSTEM*/
+#ifdef WITHOUT_GNU_PTH /* Give the Makefile a chance to build without Pth. */
+# undef HAVE_PTH
+# undef USE_GNU_PTH
+#endif
+
+#ifdef HAVE_PTH
+# include <pth.h>
+#endif
+
+
#ifdef HTTP_USE_GNUTLS
# include <gnutls/gnutls.h>
/* For non-understandable reasons GNUTLS dropped the _t suffix from
@@ -75,13 +85,13 @@ typedef gnutls_transport_ptr gnutls_transport_ptr_t;
#include "i18n.h"
#include "http.h"
#ifdef USE_DNS_SRV
-#include "srv.h"
+# include "srv.h"
#else /*!USE_DNS_SRV*/
-/* If we are not compiling with SRV record support we provide stub
- data structures. */
-#ifndef MAXDNAME
-#define MAXDNAME 1025
-#endif
+ /* If we are not compiling with SRV record support we provide stub
+ data structures. */
+# ifndef MAXDNAME
+# define MAXDNAME 1025
+# endif
struct srventry
{
unsigned short priority;
@@ -110,6 +120,15 @@ struct srventry
"01234567890@" \
"!\"#$%&'()*+,-./:;<=>?[\\]^_{|}~"
+/* A long counter type. */
+#ifdef HAVE_STRTOULL
+typedef unsigned long long longcounter_t;
+# define counter_strtoul(a) strtoull ((a), NULL, 10)
+#else
+typedef unsigned long longcounter_t;
+# define counter_strtoul(a) strtoul ((a), NULL, 10)
+#endif
+
/* Define a prefix to map stream functions to the estream library. */
#ifdef HTTP_USE_ESTREAM
#define P_ES(a) es_ ## a
@@ -152,9 +171,19 @@ static es_cookie_io_functions_t cookie_functions =
struct cookie_s
{
- int fd; /* File descriptor or -1 if already closed. */
- gnutls_session_t tls_session; /* TLS session context or NULL if not used. */
- int keep_socket; /* Flag to communicate with teh close handler. */
+ /* File descriptor or -1 if already closed. */
+ int fd;
+
+ /* TLS session context or NULL if not used. */
+ gnutls_session_t tls_session;
+
+ /* The remaining content length and a flag telling whether to use
+ the content length. */
+ longcounter_t content_length;
+ unsigned int content_length_valid:1;
+
+ /* Flag to communicate with the close handler. */
+ unsigned int keep_socket:1;
};
typedef struct cookie_s *cookie_t;
@@ -180,17 +209,18 @@ struct http_context_s
{
unsigned int status_code;
int sock;
- int in_data;
+ unsigned int in_data:1;
+ unsigned int is_http_0_9:1;
#ifdef HTTP_USE_ESTREAM
estream_t fp_read;
estream_t fp_write;
void *write_cookie;
+ void *read_cookie;
#else /*!HTTP_USE_ESTREAM*/
FILE *fp_read;
FILE *fp_write;
#endif /*!HTTP_USE_ESTREAM*/
void *tls_context;
- int is_http_0_9;
parsed_uri_t uri;
http_req_t req_type;
char *buffer; /* Line buffer. */
@@ -417,7 +447,10 @@ http_wait_response (http_t hd)
hd->write_cookie = NULL;
#endif
- if (!(hd->flags & HTTP_FLAG_NO_SHUTDOWN))
+ /* Shutdown one end of the socket is desired. As per HTTP/1.0 this
+ is not required but some very old servers (e.g. the original pksd
+ key server didn't worked without it. */
+ if ((hd->flags & HTTP_FLAG_SHUTDOWN))
shutdown (hd->sock, 1);
hd->in_data = 0;
@@ -537,7 +570,9 @@ http_get_status_code (http_t hd)
gpg_error_t
http_parse_uri (parsed_uri_t * ret_uri, const char *uri)
{
- *ret_uri = xcalloc (1, sizeof **ret_uri + strlen (uri));
+ *ret_uri = xtrycalloc (1, sizeof **ret_uri + strlen (uri));
+ if (!*ret_uri)
+ return gpg_error_from_syserror ();
strcpy ((*ret_uri)->buffer, uri);
return do_parse_uri (*ret_uri, 0);
}
@@ -980,29 +1015,16 @@ send_request (http_t hd, const char *auth,
if (!p)
return gpg_error_from_syserror ();
- request = xtrymalloc (2 * strlen (server)
- + strlen (p)
- + (authstr?strlen(authstr):0)
- + (proxy_authstr?strlen(proxy_authstr):0)
- + 100);
- if (!request)
- {
- err = gpg_error_from_syserror ();
- xfree (p);
- xfree (authstr);
- xfree (proxy_authstr);
- return err;
- }
-
if (http_proxy && *http_proxy)
{
- sprintf (request, "%s http://%s:%hu%s%s HTTP/1.0\r\n%s%s",
- hd->req_type == HTTP_REQ_GET ? "GET" :
- hd->req_type == HTTP_REQ_HEAD ? "HEAD" :
- hd->req_type == HTTP_REQ_POST ? "POST" : "OOPS",
- server, port, *p == '/' ? "" : "/", p,
- authstr ? authstr : "",
- proxy_authstr ? proxy_authstr : "");
+ request = xtryasprintf
+ ("%s http://%s:%hu%s%s HTTP/1.0\r\n%s%s",
+ hd->req_type == HTTP_REQ_GET ? "GET" :
+ hd->req_type == HTTP_REQ_HEAD ? "HEAD" :
+ hd->req_type == HTTP_REQ_POST ? "POST" : "OOPS",
+ server, port, *p == '/' ? "" : "/", p,
+ authstr ? authstr : "",
+ proxy_authstr ? proxy_authstr : "");
}
else
{
@@ -1011,16 +1033,24 @@ send_request (http_t hd, const char *auth,
if (port == 80)
*portstr = 0;
else
- sprintf (portstr, ":%u", port);
+ snprintf (portstr, sizeof portstr, ":%u", port);
- sprintf (request, "%s %s%s HTTP/1.0\r\nHost: %s%s\r\n%s",
- hd->req_type == HTTP_REQ_GET ? "GET" :
- hd->req_type == HTTP_REQ_HEAD ? "HEAD" :
- hd->req_type == HTTP_REQ_POST ? "POST" : "OOPS",
- *p == '/' ? "" : "/", p, server, portstr,
- authstr? authstr:"");
+ request = xtryasprintf
+ ("%s %s%s HTTP/1.0\r\nHost: %s%s\r\n%s",
+ hd->req_type == HTTP_REQ_GET ? "GET" :
+ hd->req_type == HTTP_REQ_HEAD ? "HEAD" :
+ hd->req_type == HTTP_REQ_POST ? "POST" : "OOPS",
+ *p == '/' ? "" : "/", p, server, portstr,
+ authstr? authstr:"");
}
xfree (p);
+ if (!request)
+ {
+ err = gpg_error_from_syserror ();
+ xfree (authstr);
+ xfree (proxy_authstr);
+ return err;
+ }
#ifdef HTTP_USE_ESTREAM
@@ -1072,18 +1102,16 @@ send_request (http_t hd, const char *auth,
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)
+ if (!err)
+ for (;headers;headers=headers->next)
{
- err = write_server( hd->sock, headers->d, strlen(headers->d) );
- if(err)
+ err = write_server (hd->sock, headers->d, strlen(headers->d));
+ if (err)
break;
- err = write_server( hd->sock, "\r\n", 2 );
- if(err)
+ err = write_server (hd->sock, "\r\n", 2);
+ if (err)
break;
}
-
if (!err)
{
hd->fp_write = fdopen (hd->sock, "w");
@@ -1351,9 +1379,7 @@ store_header (http_t hd, char *line)
is valid as along as HD has not been closed and no othe request has
been send. If the header was not found, NULL is returned. Name
must be canonicalized, that is the first letter of each dash
- delimited part must be uppercase and all other letters lowercase.
- Note that the context must have been opened with the
- HTTP_FLAG_NEED_HEADER. */
+ delimited part must be uppercase and all other letters lowercase. */
const char *
http_get_header (http_t hd, const char *name)
{
@@ -1376,6 +1402,8 @@ parse_response (http_t hd)
{
char *line, *p, *p2;
size_t maxlen, len;
+ cookie_t cookie = hd->read_cookie;
+ const char *s;
/* Delete old header lines. */
while (hd->headers)
@@ -1447,7 +1475,7 @@ parse_response (http_t hd)
if ( (hd->flags & HTTP_FLAG_LOG_RESP) )
log_info ("RESP: `%.*s'\n",
(int)strlen(line)-(*line&&line[1]?2:0),line);
- if ( (hd->flags & HTTP_FLAG_NEED_HEADER) && *line )
+ if (*line)
{
gpg_error_t err = store_header (hd, line);
if (err)
@@ -1456,6 +1484,17 @@ parse_response (http_t hd)
}
while (len && *line);
+ cookie->content_length_valid = 0;
+ if (!(hd->flags & HTTP_FLAG_IGNORE_CL))
+ {
+ s = http_get_header (hd, "Content-Length");
+ if (s)
+ {
+ cookie->content_length_valid = 1;
+ cookie->content_length = counter_strtoul (s);
+ }
+ }
+
return 0;
}
@@ -1601,6 +1640,7 @@ connect_server (const char *server, unsigned short port,
}
}
#else
+ (void)flags;
(void)srvtag;
#endif /*USE_DNS_SRV*/
@@ -1739,6 +1779,7 @@ write_server (int sock, const char *data, size_t length)
{
int nleft;
+ /* FIXME: We would better use pth I/O functions. */
nleft = length;
while (nleft > 0)
{
@@ -1787,6 +1828,14 @@ cookie_read (void *cookie, void *buffer, size_t size)
cookie_t c = cookie;
int nread;
+ if (c->content_length_valid)
+ {
+ if (!c->content_length)
+ return 0; /* EOF */
+ if (c->content_length < size)
+ size = c->content_length;
+ }
+
#ifdef HTTP_USE_GNUTLS
if (c->tls_session)
{
@@ -1817,7 +1866,9 @@ cookie_read (void *cookie, void *buffer, size_t size)
{
do
{
-#ifdef HAVE_W32_SYSTEM
+#ifdef HAVE_PTH
+ nread = pth_read (c->fd, buffer, size);
+#elif defined(HAVE_W32_SYSTEM)
/* Under Windows we need to use recv for a socket. */
nread = recv (c->fd, buffer, size, 0);
#else
@@ -1827,6 +1878,14 @@ cookie_read (void *cookie, void *buffer, size_t size)
while (nread == -1 && errno == EINTR);
}
+ if (c->content_length_valid && nread > 0)
+ {
+ if (nread < c->content_length)
+ c->content_length -= nread;
+ else
+ c->content_length = 0;
+ }
+
return nread;
}
@@ -2028,9 +2087,7 @@ main (int argc, char **argv)
http_release_parsed_uri (uri);
uri = NULL;
- rc = http_open_document (&hd, *argv, NULL,
- HTTP_FLAG_NO_SHUTDOWN | HTTP_FLAG_NEED_HEADER,
- NULL, tls_session);
+ rc = http_open_document (&hd, *argv, NULL, 0, NULL, tls_session);
if (rc)
{
log_error ("can't get `%s': %s\n", *argv, gpg_strerror (rc));
diff --git a/common/http.h b/common/http.h
index e7120f561..b00d87a3f 100644
--- a/common/http.h
+++ b/common/http.h
@@ -1,6 +1,6 @@
/* http.h - HTTP protocol handler
- * Copyright (C) 1999, 2000, 2001, 2003,
- * 2006 Free Software Foundation, Inc.
+ * Copyright (C) 1999, 2000, 2001, 2003, 2006,
+ * 2010 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -62,9 +62,9 @@ http_req_t;
enum
{
HTTP_FLAG_TRY_PROXY = 1,
- HTTP_FLAG_NO_SHUTDOWN = 2,
- HTTP_FLAG_LOG_RESP = 4,
- HTTP_FLAG_NEED_HEADER = 8
+ HTTP_FLAG_SHUTDOWN = 2,
+ HTTP_FLAG_LOG_RESP = 8,
+ HTTP_FLAG_IGNORE_CL = 32
};
struct http_context_s;
diff --git a/common/util.h b/common/util.h
index 2735cef3d..fdea333b5 100644
--- a/common/util.h
+++ b/common/util.h
@@ -27,6 +27,9 @@
#ifndef GPG_ERR_MISSING_KEY
#define GPG_ERR_MISSING_KEY 181
#endif
+#ifndef GPG_ERR_LIMIT_REACHED
+#define GPG_ERR_LIMIT_REACHED 183
+#endif
/* Hash function used with libksba. */
#define HASH_FNC ((void (*)(void *, const void*,size_t))gcry_md_write)
@@ -128,6 +131,7 @@ struct b64state
int idx;
int quad_count;
FILE *fp;
+ estream_t stream;
char *title;
unsigned char radbuf[4];
u32 crc;
@@ -136,6 +140,8 @@ struct b64state
};
gpg_error_t b64enc_start (struct b64state *state, FILE *fp, const char *title);
+gpg_error_t b64enc_start_es (struct b64state *state, estream_t fp,
+ const char *title);
gpg_error_t b64enc_write (struct b64state *state,
const void *buffer, size_t nbytes);
gpg_error_t b64enc_finish (struct b64state *state);