aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/transfer.c28
-rw-r--r--lib/urldata.h1
2 files changed, 27 insertions, 2 deletions
diff --git a/lib/transfer.c b/lib/transfer.c
index bf67788c2..5786ce777 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -379,10 +379,22 @@ _Transfer(struct connectdata *c_conn)
*/
conn->bits.close = TRUE; /* close when done */
}
+ else if (strnequal("Transfer-Encoding: chunked", p,
+ strlen("Transfer-Encoding: chunked"))) {
+ /*
+ * [RFC 2616, section 3.6.1] A 'chunked' transfer encoding
+ * means that the server will send a series of "chunks". Each
+ * chunk starts with line with info (including size of the
+ * coming block) (terminated with CRLF), then a block of data
+ * with the previously mentioned size. There can be any amount
+ * of chunks, and a chunk-data set to zero signals the
+ * end-of-chunks. */
+ conn->bits.chunk = TRUE; /* chunks coming our way */
+ }
else if (strnequal("Content-Range", p, 13)) {
if (sscanf (p+13, ": bytes %d-", &offset) ||
sscanf (p+13, ": bytes: %d-", &offset)) {
- /* This second format was added August 1st by Igor
+ /* This second format was added August 1st 2000 by Igor
Khristophorov since Sun's webserver JavaWebServer/1.1.1
obviously sends the header this way! :-( */
if (data->resume_from == offset) {
@@ -457,9 +469,14 @@ _Transfer(struct connectdata *c_conn)
is non-headers. */
if (str && !header && ((signed int)nread > 0)) {
+ /*
+ * If we requested a HTTP header, this might be a good time to get
+ * out and return home.
+ */
+
if(0 == bodywrites) {
/* These checks are only made the first time we are about to
- write a chunk of the body */
+ write a piece of the body */
if(conn->protocol&PROT_HTTP) {
/* HTTP-only checks */
if (data->newurl) {
@@ -516,6 +533,13 @@ _Transfer(struct connectdata *c_conn)
} /* this is the first time we write a body part */
bodywrites++;
+ if(conn->bits.chunk) {
+ /*
+ * Bless me father for I have sinned. Here come a chunked
+ * transfer flighing and we need to decode this properly.
+ */
+ }
+
if(conn->maxdownload &&
(bytecount + nread >= conn->maxdownload)) {
nread = conn->maxdownload - bytecount;
diff --git a/lib/urldata.h b/lib/urldata.h
index 86dee2101..40e9e5c43 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -196,6 +196,7 @@ struct FILE {
struct ConnectBits {
bool close; /* if set, we close the connection after this request */
bool reuse; /* if set, this is a re-used connection */
+ bool chunk; /* if set, this is a chunked transfer-encoding */
};
/*