[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 18/220: HTTP: use chunked Transfer-Encoding for HTT
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 18/220: HTTP: use chunked Transfer-Encoding for HTTP_POST if size unknown |
Date: |
Thu, 12 Sep 2019 17:26:18 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit 802aa5ae27ce755b94477976397502dc056227c4
Author: Balazs Kovacsics <address@hidden>
AuthorDate: Mon Jul 22 14:37:37 2019 +0200
HTTP: use chunked Transfer-Encoding for HTTP_POST if size unknown
If using the read callback for HTTP_POST, and POSTFIELDSIZE is not set,
automatically add a Transfer-Encoding: chunked header, same as it is
already done for HTTP_PUT, HTTP_POST_FORM and HTTP_POST_MIME. Update
test 1514 according to the new behaviour.
Closes #4138
---
docs/libcurl/opts/CURLOPT_POST.3 | 5 +++--
lib/http.c | 5 +++--
tests/data/test1514 | 17 ++++++++++++++++-
3 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/docs/libcurl/opts/CURLOPT_POST.3 b/docs/libcurl/opts/CURLOPT_POST.3
index 66e5c6ac7..2f3d43d67 100644
--- a/docs/libcurl/opts/CURLOPT_POST.3
+++ b/docs/libcurl/opts/CURLOPT_POST.3
@@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____|
.\" *
-.\" * Copyright (C) 1998 - 2018, Daniel Stenberg, <address@hidden>, et al.
+.\" * Copyright (C) 1998 - 2019, 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
@@ -55,7 +55,8 @@ If you use POST to an HTTP 1.1 server, you can send data
without knowing the
size before starting the POST if you use chunked encoding. You enable this by
adding a header like "Transfer-Encoding: chunked" with
\fICURLOPT_HTTPHEADER(3)\fP. With HTTP 1.0 or without chunked transfer, you
-must specify the size in the request.
+must specify the size in the request. (Since 7.66.0, libcurl will
+automatically use chunked encoding for POSTs if the size is unknown.)
When setting \fICURLOPT_POST(3)\fP to 1, libcurl will automatically set
\fICURLOPT_NOBODY(3)\fP and \fICURLOPT_HTTPGET(3)\fP to 0.
diff --git a/lib/http.c b/lib/http.c
index 36e94f762..065a26817 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -2247,8 +2247,9 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
else {
if((conn->handler->protocol & PROTO_FAMILY_HTTP) &&
(((httpreq == HTTPREQ_POST_MIME || httpreq == HTTPREQ_POST_FORM) &&
- http->postsize < 0) ||
- (data->set.upload && data->state.infilesize == -1))) {
+ http->postsize < 0) ||
+ ((data->set.upload || httpreq == HTTPREQ_POST) &&
+ data->state.infilesize == -1))) {
if(conn->bits.authneg)
/* don't enable chunked during auth neg */
;
diff --git a/tests/data/test1514 b/tests/data/test1514
index 38f5da61f..6c09ae3b0 100644
--- a/tests/data/test1514
+++ b/tests/data/test1514
@@ -4,13 +4,14 @@
HTTP
HTTP POST
Content-Length
+chunked Transfer-Encoding
</keywords>
</info>
# Server-side
<reply>
<data nocheck="yes">
-HTTP/1.1 411 Length Required
+HTTP/1.1 200 OK
Date: Sun, 19 Jan 2014 18:50:58 GMT
Server: test-server/fake swsclose
Connection: close
@@ -36,13 +37,27 @@ http://%HOSTIP:%HTTPPORT/1514
# Verify data after the test has been "shot"
<verify>
# Content-Length header is not present
+# Transfer-Encoding header is added automatically
<protocol>
POST /1514 HTTP/1.1
Host: %HOSTIP:%HTTPPORT
Accept: */*
+Transfer-Encoding: chunked
Content-Type: application/x-www-form-urlencoded
Expect: 100-continue
+1
+d
+1
+u
+1
+m
+1
+m
+1
+y
+0
+
</protocol>
</verify>
</testcase>
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [GNUnet-SVN] [gnurl] 11/220: tool_operate: fix implicit call to easysrc_cleanup, (continued)
- [GNUnet-SVN] [gnurl] 11/220: tool_operate: fix implicit call to easysrc_cleanup, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 17/220: winbuild: add vquic to list of build directories, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 12/220: multi: call detach_connection before Curl_disconnect, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 13/220: ssh-libssh: do not specify O_APPEND when not in append mode, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 20/220: http2_recv: trigger another read when the last data is returned, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 19/220: curl: avoid uncessary libcurl timeouts (in parallel mode), gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 16/220: easy: resize receive buffer on easy handle reset, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 26/220: mailmap: Amit Katyal, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 25/220: asyn-thread: removed unused variable, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 23/220: asyn-thread: create a socketpair to wait on, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 18/220: HTTP: use chunked Transfer-Encoding for HTTP_POST if size unknown,
gnunet <=
- [GNUnet-SVN] [gnurl] 24/220: RELEASE-NOTES: synced, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 15/220: examples: Avoid reserved names in hiperfifo examples, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 14/220: RELEASE-NOTES: synced, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 21/220: progress: reset download/uploaded counter, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 22/220: curl: cap the maximum allowed values for retry time arguments, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 04/220: docs/MANUAL.md: converted to markdown from plain text, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 09/220: HTTP3: initial (experimental) support, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 05/220: curl: support parallel transfers, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 31/220: ntlm: explicit type casting, gnunet, 2019/09/12
- [GNUnet-SVN] [gnurl] 38/220: mailmap: add Giorgos Oikonomou, gnunet, 2019/09/12