[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 88/150: header callback: don't chop headers into sm
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 88/150: header callback: don't chop headers into smaller pieces |
Date: |
Fri, 30 Mar 2018 16:49:02 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit 367689d8c91228139af735b51ae9ec4968e2df3d
Author: Daniel Stenberg <address@hidden>
AuthorDate: Fri Feb 16 10:23:44 2018 +0100
header callback: don't chop headers into smaller pieces
Reported-by: Guido Berhoerster
Fixes #2314
Closes #2316
---
lib/easy.c | 6 ++----
lib/sendf.c | 56 ++++++++++++++++++++++++++++++--------------------------
lib/sendf.h | 4 +---
3 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/lib/easy.c b/lib/easy.c
index 4ebec7cf5..64c647be2 100644
--- a/lib/easy.c
+++ b/lib/easy.c
@@ -1079,10 +1079,8 @@ CURLcode curl_easy_pause(struct Curl_easy *data, int
action)
/* even if one function returns error, this loops through and frees all
buffers */
if(!result)
- result = Curl_client_chop_write(conn,
- writebuf[i].type,
- writebuf[i].buf,
- writebuf[i].len);
+ result = Curl_client_write(conn, writebuf[i].type, writebuf[i].buf,
+ writebuf[i].len);
free(writebuf[i].buf);
}
diff --git a/lib/sendf.c b/lib/sendf.c
index 0fca81555..227d1fc6a 100644
--- a/lib/sendf.c
+++ b/lib/sendf.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <address@hidden>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <address@hidden>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -541,18 +541,20 @@ static CURLcode pausewrite(struct Curl_easy *data,
}
-/* Curl_client_chop_write() writes chunks of data not larger than
- * CURL_MAX_WRITE_SIZE via client write callback(s) and
- * takes care of pause requests from the callbacks.
+/* chop_write() writes chunks of data not larger than CURL_MAX_WRITE_SIZE via
+ * client write callback(s) and takes care of pause requests from the
+ * callbacks.
*/
-CURLcode Curl_client_chop_write(struct connectdata *conn,
- int type,
- char *ptr,
- size_t len)
+static CURLcode chop_write(struct connectdata *conn,
+ int type,
+ char *optr,
+ size_t olen)
{
struct Curl_easy *data = conn->data;
curl_write_callback writeheader = NULL;
curl_write_callback writebody = NULL;
+ char *ptr = optr;
+ size_t len = olen;
if(!len)
return CURLE_OK;
@@ -598,26 +600,28 @@ CURLcode Curl_client_chop_write(struct connectdata *conn,
}
}
- if(writeheader) {
- size_t wrote;
- Curl_set_in_callback(data, true);
- wrote = writeheader(ptr, 1, chunklen, data->set.writeheader);
- Curl_set_in_callback(data, false);
+ ptr += chunklen;
+ len -= chunklen;
+ }
- if(CURL_WRITEFUNC_PAUSE == wrote)
- /* here we pass in the HEADER bit only since if this was body as well
- then it was passed already and clearly that didn't trigger the
- pause, so this is saved for later with the HEADER bit only */
- return pausewrite(data, CLIENTWRITE_HEADER, ptr, len);
+ if(writeheader) {
+ size_t wrote;
+ ptr = optr;
+ len = olen;
+ Curl_set_in_callback(data, true);
+ wrote = writeheader(ptr, 1, len, data->set.writeheader);
+ Curl_set_in_callback(data, false);
- if(wrote != chunklen) {
- failf(data, "Failed writing header");
- return CURLE_WRITE_ERROR;
- }
- }
+ if(CURL_WRITEFUNC_PAUSE == wrote)
+ /* here we pass in the HEADER bit only since if this was body as well
+ then it was passed already and clearly that didn't trigger the
+ pause, so this is saved for later with the HEADER bit only */
+ return pausewrite(data, CLIENTWRITE_HEADER, ptr, len);
- ptr += chunklen;
- len -= chunklen;
+ if(wrote != len) {
+ failf(data, "Failed writing header");
+ return CURLE_WRITE_ERROR;
+ }
}
return CURLE_OK;
@@ -661,7 +665,7 @@ CURLcode Curl_client_write(struct connectdata *conn,
#endif /* CURL_DO_LINEEND_CONV */
}
- return Curl_client_chop_write(conn, type, ptr, len);
+ return chop_write(conn, type, ptr, len);
}
CURLcode Curl_read_plain(curl_socket_t sockfd,
diff --git a/lib/sendf.h b/lib/sendf.h
index fbe4f99c8..7c9134dec 100644
--- a/lib/sendf.h
+++ b/lib/sendf.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2014, Daniel Stenberg, <address@hidden>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <address@hidden>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -51,8 +51,6 @@ void Curl_failf(struct Curl_easy *, const char *fmt, ...);
#define CLIENTWRITE_HEADER (1<<1)
#define CLIENTWRITE_BOTH (CLIENTWRITE_BODY|CLIENTWRITE_HEADER)
-CURLcode Curl_client_chop_write(struct connectdata *conn, int type, char *ptr,
- size_t len) WARN_UNUSED_RESULT;
CURLcode Curl_client_write(struct connectdata *conn, int type, char *ptr,
size_t len) WARN_UNUSED_RESULT;
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 63/150: sha256: avoid redefine, (continued)
- [GNUnet-SVN] [gnurl] 63/150: sha256: avoid redefine, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 79/150: non-ascii: fix implicit declaration warning, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 84/150: CURLOPT_HEADERFUNCTION.3: mention folded headers, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 91/150: TODO: "Support in-memory certs/ca certs/keys", gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 107/150: winbuild: Use macros for the names of some build utilities, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 93/150: examples/sftpuploadresume: resume upload via CURLOPT_APPEND, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 97/150: url: Add option CURLOPT_HAPPY_EYEBALLS_TIMEOUT, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 87/150: test1154: verify that long HTTP headers get rejected, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 99/150: sasl: prefer PLAIN mechanism over LOGIN, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 123/150: RELEASE-NOTES/THANKS: synced with cc1d4c505, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 88/150: header callback: don't chop headers into smaller pieces,
gnunet <=
- [GNUnet-SVN] [gnurl] 113/150: travis: update compiler versions, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 118/150: NO_PROXY: fix for IPv6 numericals in the URL, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 132/150: SECURITY.md: call it the security process, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 100/150: lib: CURLOPT_HAPPY_EYEBALLS_TIMEOUT => CURLOPT_HAPPY_EYEBALLS_TIMEOUT_MS, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 117/150: build: get CFLAGS (including -werror) used for examples and tests, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 114/150: unit1309: fix warning on Windows x64, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 135/150: BUGS: updated link to security process, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 142/150: FAQ: fix a broken URL [ci skip], gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 145/150: limit-rate: fix compiler warning, gnunet, 2018/03/30
- [GNUnet-SVN] [gnurl] 140/150: credits: Viktor prefers without accent, gnunet, 2018/03/30