Lines Matching refs:ch
78 void Curl_httpchunk_init(struct Curl_easy *data, struct Curl_chunker *ch,
82 ch->hexindex = 0; /* start at 0 */
83 ch->state = CHUNK_HEX; /* we get hex first! */
84 ch->last_code = CHUNKE_OK;
85 Curl_dyn_init(&ch->trailer, DYN_H1_TRAILER);
86 ch->ignore_body = ignore_body;
89 void Curl_httpchunk_reset(struct Curl_easy *data, struct Curl_chunker *ch,
93 ch->hexindex = 0; /* start at 0 */
94 ch->state = CHUNK_HEX; /* we get hex first! */
95 ch->last_code = CHUNKE_OK;
96 Curl_dyn_reset(&ch->trailer);
97 ch->ignore_body = ignore_body;
100 void Curl_httpchunk_free(struct Curl_easy *data, struct Curl_chunker *ch)
103 Curl_dyn_free(&ch->trailer);
106 bool Curl_httpchunk_is_done(struct Curl_easy *data, struct Curl_chunker *ch)
109 return ch->state == CHUNK_DONE;
113 struct Curl_chunker *ch,
123 if(ch->state == CHUNK_DONE)
125 if(ch->state == CHUNK_FAILED)
130 if(data->set.http_te_skip && !ch->ignore_body) {
136 ch->state = CHUNK_FAILED;
137 ch->last_code = CHUNKE_PASSTHRU_ERROR;
143 switch(ch->state) {
146 if(ch->hexindex >= CHUNK_MAXNUM_LEN) {
148 ch->state = CHUNK_FAILED;
149 ch->last_code = CHUNKE_TOO_LONG_HEX; /* longer than we support */
152 ch->hexbuffer[ch->hexindex++] = *buf;
158 if(0 == ch->hexindex) {
162 ch->state = CHUNK_FAILED;
163 ch->last_code = CHUNKE_ILLEGAL_HEX;
168 ch->hexbuffer[ch->hexindex] = 0;
169 if(curlx_strtoofft(ch->hexbuffer, &endptr, 16, &ch->datasize)) {
170 failf(data, "chunk hex-length not valid: '%s'", ch->hexbuffer);
171 ch->state = CHUNK_FAILED;
172 ch->last_code = CHUNKE_ILLEGAL_HEX;
175 ch->state = CHUNK_LF; /* now wait for the CRLF */
183 if(0 == ch->datasize) {
184 ch->state = CHUNK_TRAILER; /* now check for trailers */
187 ch->state = CHUNK_DATA;
199 if(ch->datasize < (curl_off_t)blen)
200 piece = curlx_sotouz(ch->datasize);
203 if(!data->set.http_te_skip && !ch->ignore_body) {
211 ch->state = CHUNK_FAILED;
212 ch->last_code = CHUNKE_PASSTHRU_ERROR;
218 ch->datasize -= piece; /* decrease amount left to expect */
222 if(0 == ch->datasize)
224 ch->state = CHUNK_POSTLF;
230 Curl_httpchunk_reset(data, ch, ch->ignore_body);
233 ch->state = CHUNK_FAILED;
234 ch->last_code = CHUNKE_BAD_CHUNK;
243 char *tr = Curl_dyn_ptr(&ch->trailer);
249 result = Curl_dyn_addn(&ch->trailer, (char *)STRCONST("\x0d\x0a"));
251 ch->state = CHUNK_FAILED;
252 ch->last_code = CHUNKE_OUT_OF_MEMORY;
255 tr = Curl_dyn_ptr(&ch->trailer);
256 trlen = Curl_dyn_len(&ch->trailer);
269 ch->state = CHUNK_FAILED;
270 ch->last_code = CHUNKE_PASSTHRU_ERROR;
274 Curl_dyn_reset(&ch->trailer);
275 ch->state = CHUNK_TRAILER_CR;
282 ch->state = CHUNK_TRAILER_POSTCR;
287 result = Curl_dyn_addn(&ch->trailer, buf, 1);
289 ch->state = CHUNK_FAILED;
290 ch->last_code = CHUNKE_OUT_OF_MEMORY;
300 ch->state = CHUNK_TRAILER_POSTCR;
305 ch->state = CHUNK_FAILED;
306 ch->last_code = CHUNKE_BAD_CHUNK;
316 ch->state = CHUNK_TRAILER;
325 ch->state = CHUNK_STOP;
333 ch->datasize = blen;
334 ch->state = CHUNK_DONE;
338 ch->state = CHUNK_FAILED;
339 ch->last_code = CHUNKE_BAD_CHUNK;
374 struct Curl_chunker *ch,
378 return httpchunk_readwrite(data, ch, NULL, buf, blen, pconsumed);
383 struct Curl_chunker ch;
392 Curl_httpchunk_init(data, &ctx->ch, FALSE);
400 Curl_httpchunk_free(data, &ctx->ch);
415 result = httpchunk_readwrite(data, &ctx->ch, writer->next, buf, blen,
419 if(CHUNKE_PASSTHRU_ERROR == ctx->ch.last_code) {
424 Curl_chunked_strerror(ctx->ch.last_code));
430 if(CHUNK_DONE == ctx->ch.state) {