pike.git / lib / modules / Protocols.pmod / HTTP.pmod / module.pmod

version» Context lines:

pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:166:    void|Protocols.HTTP.Query con, void|string data)   {    if (!proxy || (proxy == "")) {    return do_method(method, url, query_variables, request_headers, con, data);    }    // Make sure we don't propagate our changes to the    // url and proxy objects below to the caller.    proxy = Standards.URI(proxy);    url = Standards.URI(url);    -  mapping(string:string|array(string)) proxy_headers; +  mapping(string:string|array(string)) proxy_headers = ([]);       if( user || password )    { -  if( !request_headers ) -  proxy_headers = ([]); -  else -  proxy_headers = request_headers + ([]); -  +     proxy_headers["Proxy-Authorization"] = "Basic "    + MIME.encode_base64((user || "") + ":" + (password || ""), 1); -  +  }    if (has_value(proxy->host, ":")) {    proxy_headers["host"] = "[" + proxy->host + "]:" + proxy->port;    } else {    proxy_headers["host"] = proxy->host + ":" + proxy->port;    } -  } +        if (url->scheme == "http") {    if( query_variables )    url->set_query_variables( url->get_query_variables() +    query_variables );    string web_url = (string)url;       // Note: url object is wrecked here    url->scheme = proxy->scheme;    url->host = proxy->host;    url->port = proxy->port;    query_variables = url->query = 0;    url->path = web_url; -  +  +  if (request_headers) { +  proxy_headers = request_headers + proxy_headers; +  }    } else if (url->scheme == "https") {   #ifdef HTTP_QUERY_DEBUG    werror("Proxied SSL request.\n");   #endif    if (!con || (con->host != url->host) || (con->port != url->port)) {    // Make a CONNECT request to the proxy,    // and use keep-alive to stack the real request on top.    proxy->path = url->host + ":" + url->port; -  if (!proxy_headers) proxy_headers = ([]); +     proxy_headers->connection = "keep-alive"; -  m_delete(proxy_headers, "authorization"); // Keep the proxy in the dark. +     con = do_method("CONNECT", proxy, 0, proxy_headers);    con->data(0);    if (con->status >= 300) {    // Proxy did not like us or failed to connect to the remote.    return con;    }    con->headers["connection"] = "keep-alive";    con->headers["content-length"] = "0";    con->host = url->host;    con->port = url->port;
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:538:    }    // Make sure we don't propagate our changes to the    // url and proxy objects below to the caller.    proxy = Standards.URI(proxy);    url = Standards.URI(url);       if( (< "httpu", "httpmu" >)[url->scheme] ) {    error("Asynchronous httpu or httpmu not yet supported.\n");    }    -  mapping(string:string|array(string)) proxy_headers; +  mapping(string:string|array(string)) proxy_headers = ([]);       if( user || password )    { -  if( !request_headers ) -  proxy_headers = ([]); -  else -  proxy_headers = request_headers + ([]); -  +     proxy_headers["Proxy-Authorization"] = "Basic "    + MIME.encode_base64((user || "") + ":" + (password || ""), 1); -  +  }    if (has_value(proxy->host, ":")) {    proxy_headers["host"] = "[" + proxy->host + "]:" + proxy->port;    } else {    proxy_headers["host"] = proxy->host + ":" + proxy->port;    } -  } +        if (url->scheme == "http") {    if( query_variables )    url->set_query_variables( url->get_query_variables() +    query_variables );    string web_url = (string)url;       // Note: url object is wrecked here    url->scheme = proxy->scheme;    url->host = proxy->host;    url->port = proxy->port;    query_variables = url->query = 0;    url->path = web_url; -  if (!proxy_headers) proxy_headers = request_headers; +  +  if (request_headers) { +  proxy_headers = request_headers + proxy_headers; +  }    } else if(url->scheme == "https") {   #ifdef HTTP_QUERY_DEBUG    werror("Proxied SSL request.\n");   #endif    if (!con || (con->host != url->host) || (con->port != url->port)) {    // Make a CONNECT request to the proxy,    // and use keep-alive to stack the real request on top.    proxy->path = url->host + ":" + url->port;    if (!proxy_headers) proxy_headers = ([]);    proxy_headers->connection = "keep-alive"; -  m_delete(proxy_headers, "authorization"); // Keep the proxy in the dark. +        array(mixed) orig_cb_info = ({    con->request_ok,    con->request_fail,    @con->extra_args,    });    con->set_callbacks(https_proxy_connect_ok,    https_proxy_connect_fail,    orig_cb_info,    url, method,    query_variables, -  request_headers && request_headers + ([]), +  request_headers,    data);    method = "CONNECT";    url = proxy;    data = 0;    } else {    proxy_headers = request_headers;    }    } else {    error("Can't handle proxying of %O.\n", url->scheme);    }