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

version» Context lines:

pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:63:      object do_method(string method,    string|Standards.URI url,    void|mapping query_variables,    void|mapping request_headers,    void|Protocols.HTTP.Query con, void|string data)   {    if(!con)    con = Protocols.HTTP.Query();    -  if(!request_headers) -  request_headers = ([]); -  +     if(stringp(url))    url=Standards.URI(url);       if(url->scheme!="http")    error("Protocols.HTTP can't handle %O or any other protocol than HTTP\n",    url->scheme);    -  +  if(!request_headers) +  request_headers = ([]); +  mapping default_headers = ([ +  "user-agent" : "Mozilla/4.0 compatible (Pike HTTP client)", +  "host" : url->host ]); +  +  if(url->user || url->passwd) +  default_headers->authorization = "Basic " +  + MIME.encode_base64(url->user + ":" + +  (url->password || "")); +  request_headers = default_headers | request_headers; +     string query=url->query;    if(query_variables && sizeof(query_variables))    {    if(query)    query+="&"+http_encode_query(query_variables);    else    query=http_encode_query(query_variables);    }       string path=url->path;    if(path=="") path="/";       con->sync_request(url->host,url->port,    method+" "+path+(query?("?"+query):"")+" HTTP/1.0", -  ([ -  "user-agent":"Mozilla/4.0 compatible (Pike HTTP client)", -  "host":url->host -  ]) | request_headers, data); +  request_headers, data);       if (!con->ok) return 0;    return con;   }      object get_url(string|Standards.URI url,    void|mapping query_variables,    void|mapping request_headers,    void|Protocols.HTTP.Query con)   {