diff options
Diffstat (limited to 'libs/libcurl/src/http_chunks.c')
-rw-r--r-- | libs/libcurl/src/http_chunks.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/libs/libcurl/src/http_chunks.c b/libs/libcurl/src/http_chunks.c index 2d2b3440e2..1180c0bcfa 100644 --- a/libs/libcurl/src/http_chunks.c +++ b/libs/libcurl/src/http_chunks.c @@ -30,12 +30,12 @@ #include "curl_printf.h"
#include "curl_trc.h"
#include "sendf.h" /* for the client write stuff */
-#include "dynbuf.h"
+#include "curlx/dynbuf.h"
#include "content_encoding.h"
#include "http.h"
#include "multiif.h"
-#include "strtoofft.h"
-#include "warnless.h"
+#include "curlx/strparse.h"
+#include "curlx/warnless.h"
/* The last #include files should be: */
#include "curl_memory.h"
@@ -85,7 +85,7 @@ void Curl_httpchunk_init(struct Curl_easy *data, struct Curl_chunker *ch, ch->hexindex = 0; /* start at 0 */
ch->state = CHUNK_HEX; /* we get hex first! */
ch->last_code = CHUNKE_OK;
- Curl_dyn_init(&ch->trailer, DYN_H1_TRAILER);
+ curlx_dyn_init(&ch->trailer, DYN_H1_TRAILER);
ch->ignore_body = ignore_body;
}
@@ -96,14 +96,14 @@ void Curl_httpchunk_reset(struct Curl_easy *data, struct Curl_chunker *ch, ch->hexindex = 0; /* start at 0 */
ch->state = CHUNK_HEX; /* we get hex first! */
ch->last_code = CHUNKE_OK;
- Curl_dyn_reset(&ch->trailer);
+ curlx_dyn_reset(&ch->trailer);
ch->ignore_body = ignore_body;
}
void Curl_httpchunk_free(struct Curl_easy *data, struct Curl_chunker *ch)
{
(void)data;
- Curl_dyn_free(&ch->trailer);
+ curlx_dyn_free(&ch->trailer);
}
bool Curl_httpchunk_is_done(struct Curl_easy *data, struct Curl_chunker *ch)
@@ -134,7 +134,7 @@ static CURLcode httpchunk_readwrite(struct Curl_easy *data, if(cw_next)
result = Curl_cwriter_write(data, cw_next, CLIENTWRITE_BODY, buf, blen);
else
- result = Curl_client_write(data, CLIENTWRITE_BODY, (char *)buf, blen);
+ result = Curl_client_write(data, CLIENTWRITE_BODY, buf, blen);
if(result) {
ch->state = CHUNK_FAILED;
ch->last_code = CHUNKE_PASSTHRU_ERROR;
@@ -158,6 +158,7 @@ static CURLcode httpchunk_readwrite(struct Curl_easy *data, (*pconsumed)++;
}
else {
+ const char *p;
if(0 == ch->hexindex) {
/* This is illegal data, we received junk where we expected
a hexadecimal digit. */
@@ -166,11 +167,11 @@ static CURLcode httpchunk_readwrite(struct Curl_easy *data, ch->last_code = CHUNKE_ILLEGAL_HEX;
return CURLE_RECV_ERROR;
}
-
/* blen and buf are unmodified */
ch->hexbuffer[ch->hexindex] = 0;
- if(curlx_strtoofft(ch->hexbuffer, NULL, 16, &ch->datasize)) {
- failf(data, "chunk hex-length not valid: '%s'", ch->hexbuffer);
+ p = &ch->hexbuffer[0];
+ if(curlx_str_hex(&p, &ch->datasize, CURL_OFF_T_MAX)) {
+ failf(data, "invalid chunk size: '%s'", ch->hexbuffer);
ch->state = CHUNK_FAILED;
ch->last_code = CHUNKE_ILLEGAL_HEX;
return CURLE_RECV_ERROR;
@@ -212,8 +213,7 @@ static CURLcode httpchunk_readwrite(struct Curl_easy *data, result = Curl_cwriter_write(data, cw_next, CLIENTWRITE_BODY,
buf, piece);
else
- result = Curl_client_write(data, CLIENTWRITE_BODY,
- (char *)buf, piece);
+ result = Curl_client_write(data, CLIENTWRITE_BODY, buf, piece);
if(result) {
ch->state = CHUNK_FAILED;
ch->last_code = CHUNKE_PASSTHRU_ERROR;
@@ -251,21 +251,20 @@ static CURLcode httpchunk_readwrite(struct Curl_easy *data, case CHUNK_TRAILER:
if((*buf == 0x0d) || (*buf == 0x0a)) {
- char *tr = Curl_dyn_ptr(&ch->trailer);
+ char *tr = curlx_dyn_ptr(&ch->trailer);
/* this is the end of a trailer, but if the trailer was zero bytes
there was no trailer and we move on */
if(tr) {
- size_t trlen;
- result = Curl_dyn_addn(&ch->trailer, (char *)STRCONST("\x0d\x0a"));
+ result = curlx_dyn_addn(&ch->trailer, STRCONST("\x0d\x0a"));
if(result) {
ch->state = CHUNK_FAILED;
ch->last_code = CHUNKE_OUT_OF_MEMORY;
return result;
}
- tr = Curl_dyn_ptr(&ch->trailer);
- trlen = Curl_dyn_len(&ch->trailer);
+ tr = curlx_dyn_ptr(&ch->trailer);
if(!data->set.http_te_skip) {
+ size_t trlen = curlx_dyn_len(&ch->trailer);
if(cw_next)
result = Curl_cwriter_write(data, cw_next,
CLIENTWRITE_HEADER|
@@ -282,7 +281,7 @@ static CURLcode httpchunk_readwrite(struct Curl_easy *data, return result;
}
}
- Curl_dyn_reset(&ch->trailer);
+ curlx_dyn_reset(&ch->trailer);
ch->state = CHUNK_TRAILER_CR;
if(*buf == 0x0a)
/* already on the LF */
@@ -295,7 +294,7 @@ static CURLcode httpchunk_readwrite(struct Curl_easy *data, }
}
else {
- result = Curl_dyn_addn(&ch->trailer, buf, 1);
+ result = curlx_dyn_addn(&ch->trailer, buf, 1);
if(result) {
ch->state = CHUNK_FAILED;
ch->last_code = CHUNKE_OUT_OF_MEMORY;
|