aboutsummaryrefslogtreecommitdiff
path: root/lib/http_chunks.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2001-03-13 22:16:42 +0000
committerDaniel Stenberg <daniel@haxx.se>2001-03-13 22:16:42 +0000
commit195233ed5c6aa8c325424072df7ea24074e7feff (patch)
tree40b6304b202f625ce13015f211f29d3d68518907 /lib/http_chunks.c
parent048e6545142a0d15516d0036ff714e9dc422c80b (diff)
updated the chunked state-machine to deal with the trailing CRLF that comes
after the data part
Diffstat (limited to 'lib/http_chunks.c')
-rw-r--r--lib/http_chunks.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/lib/http_chunks.c b/lib/http_chunks.c
index c11003354..89c860918 100644
--- a/lib/http_chunks.c
+++ b/lib/http_chunks.c
@@ -181,17 +181,43 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn,
length -= piece; /* decrease space left in this round */
if(0 == ch->datasize)
- /* end of data this round, go back to get a new size */
- Curl_httpchunk_init(conn);
+ /* end of data this round, we now expect a trailing CRLF */
+ ch->state = CHUNK_POSTCR;
+ break;
+
+ case CHUNK_POSTCR:
+ if(*datap == '\r') {
+ ch->state = CHUNK_POSTLF;
+ datap++;
+ length--;
+ }
+ else
+ return CHUNKE_BAD_CHUNK;
+ break;
+ case CHUNK_POSTLF:
+ if(*datap == '\n') {
+ /*
+ * The last one before we go back to hex state and start all
+ * over.
+ */
+ Curl_httpchunk_init(conn);
+ datap++;
+ length--;
+ }
+ else
+ return CHUNKE_BAD_CHUNK;
break;
+
case CHUNK_STOP:
/* If we arrive here, there is data left in the end of the buffer
even if there's no more chunks to read */
ch->dataleft = length;
return CHUNKE_STOP; /* return stop */
+#if 0
default:
return CHUNKE_STATE_ERROR;
+#endif
}
}
return CHUNKE_OK;