Home | History | Annotate | Download | only in examples

Lines Matching refs:Proxy

20  * @brief  HTTP part of the proxy. libmicrohttpd is used for the server side.
56 "Proxy-Connection",
87 struct Proxy *proxy = (struct Proxy *)cls;
92 PRINT_INFO2("http_cb_response for %s", proxy->url);
94 if(proxy->spdy_error)
97 if(0 == proxy->http_body_size && (proxy->done || !proxy->spdy_active))
103 if(!proxy->http_body_size)//nothing to write now
106 info = MHD_get_connection_info (proxy->http_connection,
117 if(max >= proxy->http_body_size)
119 ret = proxy->http_body_size;
125 if(NULL == (newbody = au_malloc(proxy->http_body_size - max)))
130 memcpy(newbody, proxy->http_body + max, proxy->http_body_size - max);
132 memcpy(buffer, proxy->http_body, ret);
133 free(proxy->http_body);
134 proxy->http_body = newbody;
135 proxy->http_body_size -= ret;
137 if(proxy->length >= 0)
139 proxy->length -= ret;
171 struct Proxy *proxy;
182 if(NULL == http_uri->proxy)
193 if(NULL == (proxy = au_malloc(sizeof(struct Proxy))))
202 proxy->id = rand();
203 proxy->http_active = true;
204 proxy->http_connection = connection;
205 http_uri->proxy = proxy;
209 proxy = http_uri->proxy;
211 if(proxy->spdy_error || proxy->http_error)
214 if(proxy->spdy_active)
220 int rc= spdylay_session_resume_data(proxy->spdy_connection->session, proxy->stream_id);
221 PRINT_INFO2("rc is %i stream is %i", rc, proxy->stream_id);
222 proxy->spdy_connection->want_io |= WANT_WRITE;
227 proxy->receiving_done = true;
231 if(!copy_buffer(upload_data, *upload_data_size, &proxy->received_body, &proxy->received_body_size))
252 proxy->url = http_uri->uri;
262 ret = parse_uri(&glob_opt.uri_preg, proxy->url, &proxy->uri);
265 proxy->http_uri = http_uri;
274 spdy_headers.nv[2] = ":path"; spdy_headers.nv[3] = proxy->uri->path_and_more;
276 spdy_headers.nv[6] = ":scheme"; spdy_headers.nv[7] = proxy->uri->scheme;
287 spdy_headers.nv[9] = proxy->uri->host_and_port;
289 if(0 != spdy_request(spdy_headers.nv, proxy, with_body))
292 //free_proxy(proxy);
298 proxy->http_response = MHD_create_response_from_callback (MHD_SIZE_UNKNOWN,
301 proxy,
304 if (NULL == proxy->http_response)
307 if(MHD_NO == MHD_add_response_header (proxy->http_response,
308 "Proxy-Connection", "keep-alive"))
310 if(MHD_NO == MHD_add_response_header (proxy->http_response,
313 if(MHD_NO == MHD_add_response_header (proxy->http_response,
317 proxy->spdy_active = true;
324 http_create_response(struct Proxy* proxy,
329 if(!proxy->http_active)
338 proxy->status = atoi(tmp);
343 proxy->version = nv[i+1];
352 if(MHD_NO == MHD_add_response_header (proxy->http_response,
360 if(MHD_NO == MHD_queue_response (proxy->http_connection, proxy->status, proxy->http_response)){
364 proxy->http_error = true;
367 MHD_destroy_response (proxy->http_response);
368 proxy->http_response = NULL;
380 struct Proxy *proxy;
385 proxy = (struct Proxy *)http_uri->proxy;
386 assert(NULL != proxy);
388 PRINT_INFO2("http_cb_request_completed %i for %s; id %i",toe, http_uri->uri, proxy->id);
390 if(NULL != proxy->http_response)
392 MHD_destroy_response (proxy->http_response);
393 proxy->http_response = NULL;
396 if(proxy->spdy_active)
398 proxy->http_active = false;
401 proxy->http_error = true;
402 if(proxy->stream_id > 0 /*&& NULL != proxy->spdy_connection->session*/)
405 PRINT_INFO2("send rst_stream %i %i",proxy->spdy_active, proxy->stream_id );
406 spdylay_submit_rst_stream(proxy->spdy_connection->session, proxy->stream_id, 5);
410 DLL_remove(proxy->spdy_connection->proxies_head, proxy->spdy_connection->proxies_tail, proxy);
411 free_proxy(proxy);
417 PRINT_INFO2("proxy free http id %i ", proxy->id);
418 free_proxy(proxy);