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

version» Context lines:

pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:190:    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->host = proxy->host;    url->port = proxy->port;    query_variables = url->query = 0;    url->path = web_url; - #if constant(SSL.File) +     } 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";
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:215: Inside #if constant(SSL.File)
   return con;    }    con->headers["connection"] = "keep-alive";    con->headers["content-length"] = "0";    con->host = url->host;    con->port = url->port;    con->https = 1;    con->start_tls(1);    }    proxy_headers = request_headers; - #endif /* constant(SSL.File) */ +     } else {    error("Can't handle proxying of %O.\n", url->scheme);    }       return do_method(method, url, query_variables, proxy_headers, con, data);   }      //! Low level HTTP call method.   //!   //! @param method
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:262:    url=Standards.URI(url);       if( (< "httpu", "httpmu" >)[url->scheme] ) {    return do_udp_method(method, url, query_variables, request_headers,    con, data);    }       if(!con)    con = .Query();    - #if constant(SSL.File) +     if(url->scheme!="http" && url->scheme!="https")    error("Can't handle %O or any other protocols than HTTP or HTTPS.\n",    url->scheme);       con->https = (url->scheme=="https")? 1 : 0; - #else -  if(url->scheme!="http") -  error("Can't handle %O or any other protocol than HTTP " -  "(HTTPS requires Nettle support).\n", -  url->scheme); - #endif /* constant(SSL.File) */ +        mapping default_headers = ([    "user-agent" : "Mozilla/5.0 (compatible; MSIE 6.0; Pike HTTP client)"    " Pike/" + __REAL_MAJOR__ + "." + __REAL_MINOR__ + "." + __REAL_BUILD__,    "host" : url->host +    (url->port!=(url->scheme=="https"?443:80)?":"+url->port:"")]);       if(url->user || url->password)    default_headers->authorization = "Basic "    + MIME.encode_base64(url->user + ":" +
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:398:    void|mapping(string:string|array(string)) request_headers,    Protocols.HTTP.Query con, void|string data)   {    if(stringp(url))    url=Standards.URI(url);       if( (< "httpu", "httpmu" >)[url->scheme] ) {    error("Asynchronous httpu or httpmu not yet supported.\n");    }    - #if constant(SSL.File) +     if(url->scheme!="http" && url->scheme!="https")    error("Can't handle %O or any other protocols than HTTP or HTTPS.\n",    url->scheme);       con->https = (url->scheme=="https")? 1 : 0; - #else -  if(url->scheme!="http") -  error("Can't handle %O or any other protocol than HTTP.\n", -  url->scheme); - #endif /* constant(SSL.File) */ +        if(!request_headers)    request_headers = ([]);    mapping default_headers = ([    "user-agent" : "Mozilla/5.0 (compatible; MSIE 6.0; Pike HTTP client)"    " Pike/" + __REAL_MAJOR__ + "." + __REAL_MINOR__ + "." + __REAL_BUILD__,    "host" : url->host +    (url->port!=(url->scheme=="https"?443:80)?":"+url->port:"")]);       if(url->user || url->password)
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:562:    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->host = proxy->host;    url->port = proxy->port;    query_variables = url->query = 0;    url->path = web_url; - #if constant(SSL.File) +     } 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";
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:593: Inside #if constant(SSL.File)
   url, method,    query_variables,    request_headers && request_headers + ([]),    data);    method = "CONNECT";    url = proxy;    data = 0;    } else {    proxy_headers = request_headers;    } - #endif +     } else {    error("Can't handle proxying of %O.\n", url->scheme);    }       do_async_method(method, url, query_variables, proxy_headers, con, data);   }      //! Sends a HTTP GET request to the server in the URL and returns the   //! created and initialized @[Query] object. @expr{0@} is returned   //! upon failure. If a query object having
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:738:   //!   //! Example:   //! @pre{   //! > Protocols.HTTP.http_encode_query( (["anna":"eva","lilith":"blue"]) );   //! Result: "lilith=blue&anna=eva"   //! > Protocols.HTTP.http_encode_query( (["&amp;":"&","'=\"":"\0\0\0\u0434"]) );   //! Result: "%27%3D%22=%00%00%00%D0%B4&%26amp%3B=%26"   //! @}   string http_encode_query(mapping(string:int|string|array(string)) variables)   { -  return Array.map((array)variables, +  return map((array)variables,    lambda(array(string|int|array(string)) v)    {    if (intp(v[1]))    return uri_encode(v[0]);    if (arrayp(v[1]))    return map(v[1], lambda (string val) {    return    uri_encode(v[0])+"="+    uri_encode(val);    })*"&";
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:894:   //!   //! @seealso   //! @[percent_decode], @[uri_encode]   {    constant replace_chars = gen_delims + sub_delims + other_chars;    return replace (s,    sprintf ("%c", ((array(int)) replace_chars)[*]),    sprintf ("%%%02X", ((array(int)) replace_chars)[*]));   }    - #if 0 - // These functions are disabled since I haven't found a way to - // implement them even remotely efficiently using pike only. /mast -  - string uri_normalize (string s) - //! Normalizes the URI-style @tt{%XX@} encoded string @[s] by decoding - //! all URI @tt{unreserved@} chars, i.e. US-ASCII digits, letters, - //! @tt{-@}, @tt{.@}, @tt{_@}, and @tt{~@}. - //! - //! Since only unreserved chars are decoded, the result is always - //! semantically equivalent to the input. It's therefore safe to use - //! this on a complete formatted URI. - //! - //! @seealso - //! @[uri_decode], @[uri_encode], @[iri_normalize] - { -  // FIXME - } -  - string iri_normalize (string s) - //! Normalizes the IRI-style UTF-8 and @tt{%XX@} encoded string @[s] - //! by decoding all IRI @tt{unreserved@} chars, i.e. everything except - //! the URI @tt{reserved@} chars and control chars. - //! - //! Since only unreserved chars are decoded, the result is always - //! semantically equivalent to the input. It's therefore safe to use - //! this on a complete formatted IRI. - //! - //! @seealso - //! @[iri_decode], @[uri_normalize] - { -  // FIXME - } -  - #endif -  +    string quoted_string_encode (string s)   //! Encodes the given string quoted to be used as content inside a   //! @tt{quoted-string@} according to @rfc{2616:2.2@}. The returned   //! string does not include the surrounding @tt{"@} chars.   //!   //! @note   //! The @tt{quoted-string@} quoting rules in @rfc{2616@} have several   //! problems:   //!   //! @ul