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

version» Context lines:

pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:58:    sscanf(url,"%[^:/]://%[^:/]:%d/%s",prot,host,port,query) == 4 ||    (port=80,sscanf(url,"%[^:/]://%[^:/]/%s",prot,host,query)) == 3 ||    (prot="http",sscanf(url,"%[^:/]:%d/%s",host,port,query)) == 3 ||    (port=80,sscanf(url,"%[^:/]/%s",host,query)) == 2 ||    (host=url,query="");       if (prot!="http")    error("Protocols.HTTP can't handle %O or any other protocol than HTTP\n",    prot);    -  if (query_variables) +  if (query_variables && sizeof(query_variables))    {    if (search(query,"?")!=-1)    query+="&"+http_encode_query(query_variables);    else    query+="?"+http_encode_query(query_variables);    }       con->sync_request(host,port,    "GET /"+query+" HTTP/1.0", -  (["user-agent": -  "Mozilla/4.0 compatible (Pike HTTP client)"]) | request_headers); +  ([ +  "user-agent":"Mozilla/4.0 compatible (Pike HTTP client)", +  "host":host +  ]) | request_headers);       if (!con->ok) return 0;    return con;   }      object put_url(string url, void|string file, void|mapping query_variables,    void|mapping request_headers)   {    object con=master()->resolv("Protocols")["HTTP"]["Query"]();   
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:96:    sscanf(url,"%[^:/]://%[^:/]:%d/%s",prot,host,port,query) == 4 ||    (port=80,sscanf(url,"%[^:/]://%[^:/]/%s",prot,host,query)) == 3 ||    (prot="http",sscanf(url,"%[^:/]:%d/%s",host,port,query)) == 3 ||    (port=80,sscanf(url,"%[^:/]/%s",host,query)) == 2 ||    (host=url,query="");       if (prot!="http")    error("Protocols.HTTP can't handle %O or any other protocol than HTTP\n",    prot);    -  if (query_variables) +  if (query_variables && sizeof(query_variables))    {    if (search(query,"?")!=-1)    query+="&"+http_encode_query(query_variables);    else    query+="?"+http_encode_query(query_variables);    }       con->sync_request(host,port,    "PUT /"+query+" HTTP/1.0",    ([ -  "user-agent": -  "Mozilla/4.0 compatible (Pike HTTP client)" +  "user-agent":"Mozilla/4.0 compatible (Pike HTTP client)", +  "host":host    ]) | request_headers,    file);       if (!con->ok) return 0;    return con;   }      object delete_url(string url, void|mapping query_variables,    void|mapping request_headers)   {
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:137:    sscanf(url,"%[^:/]://%[^:/]:%d/%s",prot,host,port,query) == 4 ||    (port=80,sscanf(url,"%[^:/]://%[^:/]/%s",prot,host,query)) == 3 ||    (prot="http",sscanf(url,"%[^:/]:%d/%s",host,port,query)) == 3 ||    (port=80,sscanf(url,"%[^:/]/%s",host,query)) == 2 ||    (host=url,query="");       if (prot!="http")    error("Protocols.HTTP can't handle %O or any other protocol than HTTP\n",    prot);    -  if (query_variables) +  if (query_variables && sizeof(query_variables))    {    if (search(query,"?")!=-1)    query+="&"+http_encode_query(query_variables);    else    query+="?"+http_encode_query(query_variables);    }       con->sync_request(host,port,    "DELETE /"+query+" HTTP/1.0", -  (["user-agent": -  "Mozilla/4.0 compatible (Pike HTTP client)"]) | +  ([ +  "user-agent":"Mozilla/4.0 compatible (Pike HTTP client)", +  "host":host +  ]) |    request_headers);       if (!con->ok) return 0;    return con;   }      array(string) get_url_nice(string url,void|mapping query_variables, void|mapping request_headers)   {    object c=get_url(url,query_variables, request_headers);    return c && ({c->headers["content-type"],c->data()});
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:189:    (prot="http",sscanf(url,"%[^:/]:%d/%s",host,port,query)) == 3 ||    (port=80,sscanf(url,"%[^:/]/%s",host,query)) == 2 ||    (host=url,query="");       if (prot!="http")    error("Protocols.HTTP can't handle %O or any other protocol than HTTP\n",    prot);       con->sync_request(host,port,    "POST /"+query+" HTTP/1.0", -  (["user-agent": -  "Mozilla/4.0 compatible (Pike HTTP client)"]) | +  ([ +  "user-agent":"Mozilla/4.0 compatible (Pike HTTP client)", +  "host":host +  ]) |    request_headers |    (["content-type":    "application/x-www-form-urlencoded"]),    http_encode_query(query_variables));       if (!con->ok) return 0;    return con;   }      array(string) post_url_nice(string url,mapping query_variables, void|mapping request_headers)
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:262:    "!", "½", "¼", "¾", "&frac18;", "&frac38;", "&frac58;",    "&frac78;", ">", ">", "&half;", "&hyphen;", "í", "î", "¡", "ì", "¿",    "ï", "«", "(", "&lsqb;", "<", "<", "&mdash;", "µ", "·", "",    "&ndash;", "¬", "ñ", "ó", "ô", "ò", "ø", "õ", "ö", "¶", "%",    ".", "+", "±", "£", "?", "\"", "»", "®", ")",    "&rsqb;", "§", "&semi;", "­", "¹", "²", "³", "ß", "þ", "~",    "&trade;", "ú", "û", "ù", "ü", "ý", "¥", "ÿ", "&verbar;", "&", }),    );   }    - string http_encode_query(mapping variables) + string http_encode_query(mapping(string:int|string) variables)   { -  return Array.map(indices(variables), -  lambda(string ind) +  return Array.map((array)variables, +  lambda(array(string|int) v)    { -  return http_encode_string(ind)+"="+ -  http_encode_string(variables[ind]); +  if(intp(v[1])) +  return http_encode_string(v[0]); +  return http_encode_string(v[0]) + "=" + +  http_encode_string(v[1]);    })*"&";   }      string http_encode_string(string f)   {    return replace(    f,    ({ "\000", "\001", "\002", "\003", "\004", "\005", "\006", "\007",    "\010", "\011", "\012", "\013", "\014", "\015", "\016", "\017",    "\020", "\021", "\022", "\023", "\024", "\025", "\026", "\027",    "\030", "\031", "\032", "\033", "\034", "\035", "\036", "\037",    "\200", "\201", "\202", "\203", "\204", "\205", "\206", "\207",    "\210", "\211", "\212", "\213", "\214", "\215", "\216", "\217",    "\220", "\221", "\222", "\223", "\224", "\225", "\226", "\227",    "\230", "\231", "\232", "\233", "\234", "\235", "\236", "\237", -  " ", "%", "'", "\"", "+" }), +  " ", "%", "'", "\"", "+", "&", "=", "/", +  "#", ";", "\\", "<", ">" }),    ({    "%00", "%01", "%02", "%03", "%04", "%05", "%06", "%07",    "%08", "%09", "%0a", "%0b", "%0c", "%0d", "%0e", "%0f",    "%10", "%11", "%12", "%13", "%14", "%15", "%16", "%17",    "%18", "%19", "%1a", "%1b", "%1c", "%1d", "%1e", "%1f",    "%80", "%81", "%82", "%83", "%84", "%85", "%86", "%87",    "%88", "%89", "%8a", "%8b", "%8c", "%8d", "%8e", "%8f",    "%90", "%91", "%92", "%93", "%94", "%95", "%96", "%97",    "%98", "%99", "%9a", "%9b", "%9c", "%9d", "%9e", "%9f", -  "%20", "%25", "%27", "%22", "%2b"})); +  "%20", "%25", "%27", "%22", "%2b", "%26", "%3d", "%2f", +  "%23", "%3b", "%5c", "%3c", "%3e" }));   }      string http_encode_cookie(string f)   {    return replace(    f,    ({ "\000", "\001", "\002", "\003", "\004", "\005", "\006", "\007",    "\010", "\011", "\012", "\013", "\014", "\015", "\016", "\017",    "\020", "\021", "\022", "\023", "\024", "\025", "\026", "\027",    "\030", "\031", "\032", "\033", "\034", "\035", "\036", "\037",