diff --git a/lib/http_chunks.c b/lib/http_chunks.c index 83e3f0eec25b98b93077d5a5d1249408569cd90c..61a6098a7f1985035bfa56c21d4762f053e8233b 100644 --- a/lib/http_chunks.c +++ b/lib/http_chunks.c @@ -361,4 +361,25 @@ CHUNKcode Curl_httpchunk_read(struct connectdata *conn, } return CHUNKE_OK; } + +const char *Curl_chunked_strerror(CHUNKcode code) +{ + switch (code) { + default: + return "OK"; + case CHUNKE_TOO_LONG_HEX: + return "Too long hexadecimal number"; + case CHUNKE_ILLEGAL_HEX: + return "Illegal or missing hexadecimal sequence"; + case CHUNKE_BAD_CHUNK: + return "Malformed encoding found"; + case CHUNKE_WRITE_ERROR: + return "Write error"; + case CHUNKE_BAD_ENCODING: + return "Bad content-encoding found"; + case CHUNKE_OUT_OF_MEMORY: + return "Out of memory"; + } +} + #endif /* CURL_DISABLE_HTTP */ diff --git a/lib/http_chunks.h b/lib/http_chunks.h index fc652d51e5a2d826115335cf836aeac2aa33fc34..0489eb859e67d1be0654d1aadff05fd5c71b5e6a 100644 --- a/lib/http_chunks.h +++ b/lib/http_chunks.h @@ -72,12 +72,13 @@ typedef enum { CHUNKE_ILLEGAL_HEX, CHUNKE_BAD_CHUNK, CHUNKE_WRITE_ERROR, - CHUNKE_STATE_ERROR, CHUNKE_BAD_ENCODING, CHUNKE_OUT_OF_MEMORY, CHUNKE_LAST } CHUNKcode; +const char *Curl_chunked_strerror(CHUNKcode code); + struct Curl_chunker { char hexbuffer[ MAXNUM_SIZE + 1]; int hexindex; diff --git a/lib/transfer.c b/lib/transfer.c index ccaee837301349ee00130ee18efd625a2e503a8a..3fcc6003ebaeabc5c73645649fbb1c4e150ed75c 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -611,7 +611,7 @@ static CURLcode readwrite_data(struct SessionHandle *data, failf(data, "Failed writing data"); return CURLE_WRITE_ERROR; } - failf(data, "Problem (%d) in the Chunked-Encoded data", (int)res); + failf(data, "%s in chunked-encoding", Curl_chunked_strerror(res)); return CURLE_RECV_ERROR; } else if(CHUNKE_STOP == res) {