Lines Matching refs:ts
85 static bool tunnel_is_established(struct h1_tunnel_state *ts) in tunnel_is_established() argument
87 return ts && (ts->tunnel_state == H1_TUNNEL_ESTABLISHED); in tunnel_is_established()
90 static bool tunnel_is_failed(struct h1_tunnel_state *ts) in tunnel_is_failed() argument
92 return ts && (ts->tunnel_state == H1_TUNNEL_FAILED); in tunnel_is_failed()
97 struct h1_tunnel_state *ts) in tunnel_reinit() argument
101 DEBUGASSERT(ts); in tunnel_reinit()
102 Curl_dyn_reset(&ts->rcvbuf); in tunnel_reinit()
103 Curl_dyn_reset(&ts->request_data); in tunnel_reinit()
104 ts->tunnel_state = H1_TUNNEL_INIT; in tunnel_reinit()
105 ts->keepon = KEEPON_CONNECT; in tunnel_reinit()
106 ts->cl = 0; in tunnel_reinit()
107 ts->close_connection = FALSE; in tunnel_reinit()
115 struct h1_tunnel_state *ts; in tunnel_init() local
122 ts = calloc(1, sizeof(*ts)); in tunnel_init()
123 if(!ts) in tunnel_init()
128 Curl_dyn_init(&ts->rcvbuf, DYN_PROXY_CONNECT_HEADERS); in tunnel_init()
129 Curl_dyn_init(&ts->request_data, DYN_HTTP_REQUEST); in tunnel_init()
130 Curl_httpchunk_init(data, &ts->ch, TRUE); in tunnel_init()
132 *pts = ts; in tunnel_init()
134 return tunnel_reinit(cf, data, ts); in tunnel_init()
138 struct h1_tunnel_state *ts, in h1_tunnel_go_state() argument
142 if(ts->tunnel_state == new_state) in h1_tunnel_go_state()
148 tunnel_reinit(cf, data, ts); in h1_tunnel_go_state()
153 ts->tunnel_state = H1_TUNNEL_CONNECT; in h1_tunnel_go_state()
154 ts->keepon = KEEPON_CONNECT; in h1_tunnel_go_state()
155 Curl_dyn_reset(&ts->rcvbuf); in h1_tunnel_go_state()
160 ts->tunnel_state = H1_TUNNEL_RECEIVE; in h1_tunnel_go_state()
165 ts->tunnel_state = H1_TUNNEL_RESPONSE; in h1_tunnel_go_state()
177 ts->tunnel_state = new_state; in h1_tunnel_go_state()
178 Curl_dyn_reset(&ts->rcvbuf); in h1_tunnel_go_state()
179 Curl_dyn_reset(&ts->request_data); in h1_tunnel_go_state()
198 struct h1_tunnel_state *ts = cf->ctx; in tunnel_free() local
199 if(ts) { in tunnel_free()
200 h1_tunnel_go_state(cf, ts, H1_TUNNEL_FAILED, data); in tunnel_free()
201 Curl_dyn_free(&ts->rcvbuf); in tunnel_free()
202 Curl_dyn_free(&ts->request_data); in tunnel_free()
203 Curl_httpchunk_free(data, &ts->ch); in tunnel_free()
204 free(ts); in tunnel_free()
210 static bool tunnel_want_send(struct h1_tunnel_state *ts) in tunnel_want_send() argument
212 return (ts->tunnel_state == H1_TUNNEL_CONNECT); in tunnel_want_send()
218 struct h1_tunnel_state *ts) in start_CONNECT() argument
235 Curl_dyn_reset(&ts->request_data); in start_CONNECT()
236 ts->nsent = 0; in start_CONNECT()
237 ts->headerlines = 0; in start_CONNECT()
240 result = Curl_h1_req_write_head(req, http_minor, &ts->request_data); in start_CONNECT()
254 struct h1_tunnel_state *ts, in send_CONNECT() argument
257 char *buf = Curl_dyn_ptr(&ts->request_data); in send_CONNECT()
258 size_t request_len = Curl_dyn_len(&ts->request_data); in send_CONNECT()
263 if(blen <= ts->nsent) in send_CONNECT()
266 blen -= ts->nsent; in send_CONNECT()
267 buf += ts->nsent; in send_CONNECT()
278 ts->nsent += (size_t)nwritten; in send_CONNECT()
284 *done = (!result && (ts->nsent >= request_len)); in send_CONNECT()
290 struct h1_tunnel_state *ts, in on_resp_header() argument
325 NULL, 10, &ts->cl); in on_resp_header()
330 ts->close_connection = TRUE; in on_resp_header()
343 ts->chunked_encoding = TRUE; in on_resp_header()
345 Curl_httpchunk_reset(data, &ts->ch, TRUE); in on_resp_header()
351 ts->close_connection = TRUE; in on_resp_header()
366 struct h1_tunnel_state *ts, in recv_CONNECT_resp() argument
384 while(ts->keepon) { in recv_CONNECT_resp()
399 ts->keepon = KEEPON_DONE; in recv_CONNECT_resp()
408 ts->close_connection = TRUE; in recv_CONNECT_resp()
415 ts->keepon = KEEPON_DONE; in recv_CONNECT_resp()
419 if(ts->keepon == KEEPON_IGNORE) { in recv_CONNECT_resp()
422 if(ts->cl) { in recv_CONNECT_resp()
425 ts->cl--; in recv_CONNECT_resp()
426 if(ts->cl <= 0) { in recv_CONNECT_resp()
427 ts->keepon = KEEPON_DONE; in recv_CONNECT_resp()
431 else if(ts->chunked_encoding) { in recv_CONNECT_resp()
438 result = Curl_httpchunk_read(data, &ts->ch, &byte, 1, &consumed); in recv_CONNECT_resp()
441 if(Curl_httpchunk_is_done(data, &ts->ch)) { in recv_CONNECT_resp()
444 ts->keepon = KEEPON_DONE; in recv_CONNECT_resp()
450 if(Curl_dyn_addn(&ts->rcvbuf, &byte, 1)) { in recv_CONNECT_resp()
459 ts->headerlines++; in recv_CONNECT_resp()
460 linep = Curl_dyn_ptr(&ts->rcvbuf); in recv_CONNECT_resp()
461 line_len = Curl_dyn_len(&ts->rcvbuf); /* amount of bytes in this line */ in recv_CONNECT_resp()
468 (ts->headerlines == 1 ? CLIENTWRITE_STATUS : 0); in recv_CONNECT_resp()
489 ts->keepon = KEEPON_IGNORE; in recv_CONNECT_resp()
491 if(ts->cl) { in recv_CONNECT_resp()
492 infof(data, "Ignore %" FMT_OFF_T " bytes of response-body", ts->cl); in recv_CONNECT_resp()
494 else if(ts->chunked_encoding) { in recv_CONNECT_resp()
502 ts->keepon = KEEPON_DONE; in recv_CONNECT_resp()
506 ts->keepon = KEEPON_DONE; in recv_CONNECT_resp()
509 DEBUGASSERT(ts->keepon == KEEPON_IGNORE in recv_CONNECT_resp()
510 || ts->keepon == KEEPON_DONE); in recv_CONNECT_resp()
514 result = on_resp_header(cf, data, ts, linep); in recv_CONNECT_resp()
518 Curl_dyn_reset(&ts->rcvbuf); in recv_CONNECT_resp()
523 *done = (ts->keepon == KEEPON_DONE); in recv_CONNECT_resp()
571 struct h1_tunnel_state *ts) in start_CONNECT() argument
587 (void)ts; in start_CONNECT()
795 struct h1_tunnel_state *ts, in send_CONNECT() argument
804 (void)ts; in send_CONNECT()
833 struct h1_tunnel_state *ts, in recv_CONNECT_resp() argument
840 (void)ts; in recv_CONNECT_resp()
865 struct h1_tunnel_state *ts) in H1_CONNECT() argument
871 if(tunnel_is_established(ts)) in H1_CONNECT()
873 if(tunnel_is_failed(ts)) in H1_CONNECT()
886 switch(ts->tunnel_state) { in H1_CONNECT()
890 result = start_CONNECT(cf, data, ts); in H1_CONNECT()
893 h1_tunnel_go_state(cf, ts, H1_TUNNEL_CONNECT, data); in H1_CONNECT()
899 result = send_CONNECT(cf, data, ts, &done); in H1_CONNECT()
902 h1_tunnel_go_state(cf, ts, H1_TUNNEL_RECEIVE, data); in H1_CONNECT()
908 result = recv_CONNECT_resp(cf, data, ts, &done); in H1_CONNECT()
917 h1_tunnel_go_state(cf, ts, H1_TUNNEL_RESPONSE, data); in H1_CONNECT()
928 if(ts->close_connection || conn->bits.close) { in H1_CONNECT()
943 h1_tunnel_go_state(cf, ts, H1_TUNNEL_INIT, data); in H1_CONNECT()
954 DEBUGASSERT(ts->tunnel_state == H1_TUNNEL_RESPONSE); in H1_CONNECT()
960 h1_tunnel_go_state(cf, ts, H1_TUNNEL_FAILED, data); in H1_CONNECT()
965 h1_tunnel_go_state(cf, ts, H1_TUNNEL_ESTABLISHED, data); in H1_CONNECT()
972 h1_tunnel_go_state(cf, ts, H1_TUNNEL_FAILED, data); in H1_CONNECT()
981 struct h1_tunnel_state *ts = cf->ctx; in cf_h1_proxy_connect() local
994 if(!ts) { in cf_h1_proxy_connect()
995 result = tunnel_init(cf, data, &ts); in cf_h1_proxy_connect()
998 cf->ctx = ts; in cf_h1_proxy_connect()
1004 result = H1_CONNECT(cf, data, ts); in cf_h1_proxy_connect()
1028 struct h1_tunnel_state *ts = cf->ctx; in cf_h1_proxy_adjust_pollset() local
1034 if(ts) { in cf_h1_proxy_adjust_pollset()
1039 if(tunnel_want_send(ts)) in cf_h1_proxy_adjust_pollset()