Lines Matching refs:proxy
412 struct Proxy *proxy = (struct Proxy *)SPDY_get_cls_from_request(request); in spdy_post_data_cb() local
414 if(!store_in_buffer(buf, size, &proxy->received_body, &proxy->received_body_size)) in spdy_post_data_cb()
420 proxy->receiving_done = !more; in spdy_post_data_cb()
426 if(proxy->is_curl_read_paused) in spdy_post_data_cb()
428 if(CURLE_OK != (ret = curl_easy_pause(proxy->curl_handle, CURLPAUSE_CONT))) in spdy_post_data_cb()
447 struct Proxy *proxy = (struct Proxy *)cls; in response_callback() local
451 assert(!proxy->spdy_error); in response_callback()
453 if(proxy->curl_error) in response_callback()
459 if(!proxy->http_body_size)//nothing to write now in response_callback()
462 if(proxy->curl_done || proxy->curl_error) *more = false; in response_callback()
466 ret = get_from_buffer(&(proxy->http_body), &(proxy->http_body_size), buffer, max); in response_callback()
474 if((proxy->curl_done || proxy->curl_error) && 0 == proxy->http_body_size) *more = false; in response_callback()
483 cleanup(struct Proxy *proxy) in cleanup() argument
489 if(CURLM_OK != (ret = curl_multi_remove_handle(multi_handle, proxy->curl_handle))) in cleanup()
497 curl_slist_free_all(proxy->curl_headers); in cleanup()
498 curl_easy_cleanup(proxy->curl_handle); in cleanup()
500 free(proxy->url); in cleanup()
501 free(proxy); in cleanup()
513 struct Proxy *proxy = (struct Proxy *)cls; in response_done_callback() local
517 free(proxy->http_body); in response_done_callback()
518 proxy->http_body = NULL; in response_done_callback()
519 proxy->spdy_error = true; in response_done_callback()
521 cleanup(proxy); in response_done_callback()
531 struct Proxy *proxy = (struct Proxy *)userp; in curl_header_cb() local
544 if(!*(proxy->session_alive)) in curl_header_cb()
547 proxy->spdy_error = true; in curl_header_cb()
548 proxy->curl_error = true; in curl_header_cb()
553 if(NULL != proxy->response) return 0; in curl_header_cb()
558 if(NULL == (proxy->response = SPDY_build_response_with_callback(proxy->status, in curl_header_cb()
559 proxy->status_msg, in curl_header_cb()
560 proxy->version, in curl_header_cb()
561 proxy->headers, in curl_header_cb()
563 proxy, in curl_header_cb()
568 SPDY_name_value_destroy(proxy->headers); in curl_header_cb()
569 proxy->headers = NULL; in curl_header_cb()
570 free(proxy->status_msg); in curl_header_cb()
571 proxy->status_msg = NULL; in curl_header_cb()
572 free(proxy->version); in curl_header_cb()
573 proxy->version = NULL; in curl_header_cb()
575 if(SPDY_YES != SPDY_queue_response(proxy->request, in curl_header_cb()
576 proxy->response, in curl_header_cb()
580 proxy)) in curl_header_cb()
584 proxy->spdy_error = true; in curl_header_cb()
585 proxy->curl_error = true; in curl_header_cb()
586 PRINT_VERBOSE2("no queue in curl_header_cb for %s", proxy->url); in curl_header_cb()
587 SPDY_destroy_response(proxy->response); in curl_header_cb()
588 proxy->response = NULL; in curl_header_cb()
598 if(NULL == proxy->version) in curl_header_cb()
605 if(NULL == (proxy->version = strndup(line, i - pos))) in curl_header_cb()
613 proxy->status = atoi(status); in curl_header_cb()
620 if(NULL == (proxy->status_msg = strndup(&(line[pos]), i - pos))) in curl_header_cb()
623 …PRINT_VERBOSE2("Header line received '%s' '%i' '%s' ", proxy->version, proxy->status, proxy->statu… in curl_header_cb()
645 if(SPDY_YES != SPDY_name_value_add(proxy->headers, name, "")) in curl_header_cb()
657 if(SPDY_YES != (ret = SPDY_name_value_add(proxy->headers, name, value))) in curl_header_cb()
660 if(NULL != (values = SPDY_name_value_lookup(proxy->headers, name, &num_values))) in curl_header_cb()
686 struct Proxy *proxy = (struct Proxy *)userp; in curl_write_cb() local
689 if(!*(proxy->session_alive)) in curl_write_cb()
692 proxy->spdy_error = true; in curl_write_cb()
693 proxy->curl_error = true; in curl_write_cb()
697 if(!store_in_buffer(contents, realsize, &proxy->http_body, &proxy->http_body_size)) in curl_write_cb()
700 proxy->curl_error = true; in curl_write_cb()
731 struct Proxy *proxy = (struct Proxy *)userp; in curl_read_cb() local
735 if((proxy->receiving_done && !proxy->received_body_size) || !proxy->is_with_body_data || max < 1) in curl_read_cb()
741 if(!*(proxy->session_alive)) in curl_read_cb()
747 if(!proxy->received_body_size)//nothing to write now in curl_read_cb()
750 proxy->is_curl_read_paused = true; in curl_read_cb()
754 ret = get_from_buffer(&(proxy->received_body), &(proxy->received_body_size), ptr, max); in curl_read_cb()
792 struct Proxy *proxy = (struct Proxy *)cls; in iterate_cb() local
793 struct curl_slist **curl_headers = (&(proxy->curl_headers)); in iterate_cb()
846 struct Proxy *proxy; in standard_request_handler() local
851 proxy = SPDY_get_cls_from_request(request); in standard_request_handler()
852 if(NULL != proxy) in standard_request_handler()
861 if(NULL == (proxy = malloc(sizeof(struct Proxy)))) in standard_request_handler()
863 memset(proxy, 0, sizeof(struct Proxy)); in standard_request_handler()
869 proxy->session_alive = SPDY_get_cls_from_session(session); in standard_request_handler()
870 assert(NULL != proxy->session_alive); in standard_request_handler()
872 SPDY_set_cls_to_request(request, proxy); in standard_request_handler()
874 proxy->request = request; in standard_request_handler()
875 proxy->is_with_body_data = more; in standard_request_handler()
876 if(NULL == (proxy->headers = SPDY_name_value_create())) in standard_request_handler()
882 ret = asprintf(&(proxy->url),"%s://%s%s", scheme, glob_opt.http_backend, path); in standard_request_handler()
884 ret = asprintf(&(proxy->url),"%s://%s%s", scheme, host, path); in standard_request_handler()
888 ret = parse_uri(&uri_preg, proxy->url, &uri); in standard_request_handler()
901 … ret = asprintf(&(proxy->url),"%s://%s%s", uri->scheme, glob_opt.http_backend, uri->path_and_more); in standard_request_handler()
906 if(NULL == (proxy->url = strdup(path))) in standard_request_handler()
912 PRINT_VERBOSE2("curl will request '%s'", proxy->url); in standard_request_handler()
914 SPDY_name_value_iterate(headers, &iterate_cb, proxy); in standard_request_handler()
916 if(NULL == (proxy->curl_handle = curl_easy_init())) in standard_request_handler()
923 CURL_SETOPT(proxy->curl_handle, CURLOPT_VERBOSE, 1); in standard_request_handler()
927 if(NULL == (proxy->curl_headers = curl_slist_append(proxy->curl_headers, "Expect:"))) in standard_request_handler()
929 CURL_SETOPT(proxy->curl_handle, CURLOPT_POST, 1); in standard_request_handler()
930 CURL_SETOPT(proxy->curl_handle, CURLOPT_READFUNCTION, curl_read_cb); in standard_request_handler()
931 CURL_SETOPT(proxy->curl_handle, CURLOPT_READDATA, proxy); in standard_request_handler()
935 CURL_SETOPT(proxy->curl_handle, CURLOPT_TIMEOUT, glob_opt.timeout); in standard_request_handler()
936 CURL_SETOPT(proxy->curl_handle, CURLOPT_URL, proxy->url); in standard_request_handler()
938 CURL_SETOPT(proxy->curl_handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); in standard_request_handler()
939 CURL_SETOPT(proxy->curl_handle, CURLOPT_WRITEFUNCTION, curl_write_cb); in standard_request_handler()
940 CURL_SETOPT(proxy->curl_handle, CURLOPT_WRITEDATA, proxy); in standard_request_handler()
941 CURL_SETOPT(proxy->curl_handle, CURLOPT_HEADERFUNCTION, curl_header_cb); in standard_request_handler()
942 CURL_SETOPT(proxy->curl_handle, CURLOPT_HEADERDATA, proxy); in standard_request_handler()
943 CURL_SETOPT(proxy->curl_handle, CURLOPT_PRIVATE, proxy); in standard_request_handler()
944 CURL_SETOPT(proxy->curl_handle, CURLOPT_HTTPHEADER, proxy->curl_headers); in standard_request_handler()
945 CURL_SETOPT(proxy->curl_handle, CURLOPT_SSL_VERIFYPEER, 0L);//TODO in standard_request_handler()
946 CURL_SETOPT(proxy->curl_handle, CURLOPT_SSL_VERIFYHOST, 0L); in standard_request_handler()
948 CURL_SETOPT(proxy->curl_handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); in standard_request_handler()
950 CURL_SETOPT(proxy->curl_handle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V6); in standard_request_handler()
952 if(CURLM_OK != (ret = curl_multi_add_handle(multi_handle, proxy->curl_handle))) in standard_request_handler()
989 struct Proxy *proxy; in run() local
1164 proxy = (struct Proxy *)curl_private; in run()
1167 proxy->curl_done = true; in run()
1175 PRINT_VERBOSE2("bad curl result (%i) for '%s'", msg->data.result, proxy->url); in run()
1176 … if(proxy->spdy_done || proxy->spdy_error || (NULL == proxy->response && !*(proxy->session_alive))) in run()
1179 SPDY_name_value_destroy(proxy->headers); in run()
1180 SPDY_destroy_request(proxy->request); in run()
1181 SPDY_destroy_response(proxy->response); in run()
1182 cleanup(proxy); in run()
1184 else if(NULL == proxy->response && *(proxy->session_alive)) in run()
1188 SPDY_name_value_destroy(proxy->headers); in run()
1189 proxy->headers = NULL; in run()
1190 if(NULL == (proxy->response = SPDY_build_response(SPDY_HTTP_BAD_GATEWAY, in run()
1197 if(SPDY_YES != SPDY_queue_response(proxy->request, in run()
1198 proxy->response, in run()
1202 proxy)) in run()
1206 SPDY_destroy_request(proxy->request); in run()
1207 SPDY_destroy_response(proxy->response); in run()
1208 cleanup(proxy); in run()
1213 proxy->curl_error = true; in run()