Lines Matching refs:ch
81 void Curl_httpchunk_init(struct Curl_easy *data, struct Curl_chunker *ch, in Curl_httpchunk_init() argument
85 ch->hexindex = 0; /* start at 0 */ in Curl_httpchunk_init()
86 ch->state = CHUNK_HEX; /* we get hex first! */ in Curl_httpchunk_init()
87 ch->last_code = CHUNKE_OK; in Curl_httpchunk_init()
88 Curl_dyn_init(&ch->trailer, DYN_H1_TRAILER); in Curl_httpchunk_init()
89 ch->ignore_body = ignore_body; in Curl_httpchunk_init()
92 void Curl_httpchunk_reset(struct Curl_easy *data, struct Curl_chunker *ch, in Curl_httpchunk_reset() argument
96 ch->hexindex = 0; /* start at 0 */ in Curl_httpchunk_reset()
97 ch->state = CHUNK_HEX; /* we get hex first! */ in Curl_httpchunk_reset()
98 ch->last_code = CHUNKE_OK; in Curl_httpchunk_reset()
99 Curl_dyn_reset(&ch->trailer); in Curl_httpchunk_reset()
100 ch->ignore_body = ignore_body; in Curl_httpchunk_reset()
103 void Curl_httpchunk_free(struct Curl_easy *data, struct Curl_chunker *ch) in Curl_httpchunk_free() argument
106 Curl_dyn_free(&ch->trailer); in Curl_httpchunk_free()
109 bool Curl_httpchunk_is_done(struct Curl_easy *data, struct Curl_chunker *ch) in Curl_httpchunk_is_done() argument
112 return ch->state == CHUNK_DONE; in Curl_httpchunk_is_done()
116 struct Curl_chunker *ch, in httpchunk_readwrite() argument
126 if(ch->state == CHUNK_DONE) in httpchunk_readwrite()
128 if(ch->state == CHUNK_FAILED) in httpchunk_readwrite()
133 if(data->set.http_te_skip && !ch->ignore_body) { in httpchunk_readwrite()
139 ch->state = CHUNK_FAILED; in httpchunk_readwrite()
140 ch->last_code = CHUNKE_PASSTHRU_ERROR; in httpchunk_readwrite()
146 switch(ch->state) { in httpchunk_readwrite()
149 if(ch->hexindex >= CHUNK_MAXNUM_LEN) { in httpchunk_readwrite()
151 ch->state = CHUNK_FAILED; in httpchunk_readwrite()
152 ch->last_code = CHUNKE_TOO_LONG_HEX; /* longer than we support */ in httpchunk_readwrite()
155 ch->hexbuffer[ch->hexindex++] = *buf; in httpchunk_readwrite()
161 if(0 == ch->hexindex) { in httpchunk_readwrite()
165 ch->state = CHUNK_FAILED; in httpchunk_readwrite()
166 ch->last_code = CHUNKE_ILLEGAL_HEX; in httpchunk_readwrite()
171 ch->hexbuffer[ch->hexindex] = 0; in httpchunk_readwrite()
172 if(curlx_strtoofft(ch->hexbuffer, NULL, 16, &ch->datasize)) { in httpchunk_readwrite()
173 failf(data, "chunk hex-length not valid: '%s'", ch->hexbuffer); in httpchunk_readwrite()
174 ch->state = CHUNK_FAILED; in httpchunk_readwrite()
175 ch->last_code = CHUNKE_ILLEGAL_HEX; in httpchunk_readwrite()
178 ch->state = CHUNK_LF; /* now wait for the CRLF */ in httpchunk_readwrite()
186 if(0 == ch->datasize) { in httpchunk_readwrite()
187 ch->state = CHUNK_TRAILER; /* now check for trailers */ in httpchunk_readwrite()
190 ch->state = CHUNK_DATA; in httpchunk_readwrite()
192 FMT_OFF_T " bytes", ch->datasize); in httpchunk_readwrite()
206 if(ch->datasize < (curl_off_t)blen) in httpchunk_readwrite()
207 piece = curlx_sotouz(ch->datasize); in httpchunk_readwrite()
210 if(!data->set.http_te_skip && !ch->ignore_body) { in httpchunk_readwrite()
218 ch->state = CHUNK_FAILED; in httpchunk_readwrite()
219 ch->last_code = CHUNKE_PASSTHRU_ERROR; in httpchunk_readwrite()
225 ch->datasize -= piece; /* decrease amount left to expect */ in httpchunk_readwrite()
230 piece, ch->datasize); in httpchunk_readwrite()
232 if(0 == ch->datasize) in httpchunk_readwrite()
234 ch->state = CHUNK_POSTLF; in httpchunk_readwrite()
240 Curl_httpchunk_reset(data, ch, ch->ignore_body); in httpchunk_readwrite()
243 ch->state = CHUNK_FAILED; in httpchunk_readwrite()
244 ch->last_code = CHUNKE_BAD_CHUNK; in httpchunk_readwrite()
254 char *tr = Curl_dyn_ptr(&ch->trailer); in httpchunk_readwrite()
260 result = Curl_dyn_addn(&ch->trailer, (char *)STRCONST("\x0d\x0a")); in httpchunk_readwrite()
262 ch->state = CHUNK_FAILED; in httpchunk_readwrite()
263 ch->last_code = CHUNKE_OUT_OF_MEMORY; in httpchunk_readwrite()
266 tr = Curl_dyn_ptr(&ch->trailer); in httpchunk_readwrite()
267 trlen = Curl_dyn_len(&ch->trailer); in httpchunk_readwrite()
280 ch->state = CHUNK_FAILED; in httpchunk_readwrite()
281 ch->last_code = CHUNKE_PASSTHRU_ERROR; in httpchunk_readwrite()
285 Curl_dyn_reset(&ch->trailer); in httpchunk_readwrite()
286 ch->state = CHUNK_TRAILER_CR; in httpchunk_readwrite()
293 ch->state = CHUNK_TRAILER_POSTCR; in httpchunk_readwrite()
298 result = Curl_dyn_addn(&ch->trailer, buf, 1); in httpchunk_readwrite()
300 ch->state = CHUNK_FAILED; in httpchunk_readwrite()
301 ch->last_code = CHUNKE_OUT_OF_MEMORY; in httpchunk_readwrite()
312 ch->state = CHUNK_TRAILER_POSTCR; in httpchunk_readwrite()
318 ch->state = CHUNK_FAILED; in httpchunk_readwrite()
319 ch->last_code = CHUNKE_BAD_CHUNK; in httpchunk_readwrite()
329 ch->state = CHUNK_TRAILER; in httpchunk_readwrite()
339 ch->state = CHUNK_STOP; in httpchunk_readwrite()
348 ch->datasize = blen; in httpchunk_readwrite()
349 ch->state = CHUNK_DONE; in httpchunk_readwrite()
354 ch->state = CHUNK_FAILED; in httpchunk_readwrite()
355 ch->last_code = CHUNKE_BAD_CHUNK; in httpchunk_readwrite()
392 struct Curl_chunker *ch, in Curl_httpchunk_read() argument
396 return httpchunk_readwrite(data, ch, NULL, buf, blen, pconsumed); in Curl_httpchunk_read()
401 struct Curl_chunker ch; member
410 Curl_httpchunk_init(data, &ctx->ch, FALSE); in cw_chunked_init()
418 Curl_httpchunk_free(data, &ctx->ch); in cw_chunked_close()
433 result = httpchunk_readwrite(data, &ctx->ch, writer->next, buf, blen, in cw_chunked_write()
437 if(CHUNKE_PASSTHRU_ERROR == ctx->ch.last_code) { in cw_chunked_write()
442 Curl_chunked_strerror(ctx->ch.last_code)); in cw_chunked_write()
448 if(CHUNK_DONE == ctx->ch.state) { in cw_chunked_write()