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

version» Context lines:

pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:53:   // Server errors   constant HTTP_INTERNAL_ERR = 500; // RFC 2616 10.5.1: Internal Server Error   constant HTTP_NOT_IMPL = 501; // RFC 2616 10.5.2: Not Implemented   constant HTTP_BAD_GW = 502; // RFC 2616 10.5.3: Bad Gateway   constant HTTP_UNAVAIL = 503; // RFC 2616 10.5.4: Service Unavailable   constant HTTP_GW_TIMEOUT = 504; // RFC 2616 10.5.5: Gateway Timeout   constant HTTP_UNSUPP_VERSION = 505; // RFC 2616 10.5.6: HTTP Version Not Supported   constant TCN_VARIANT_NEGOTIATES = 506; // RFC 2295 8.1: Variant Also Negotiates   constant DAV_STORAGE_FULL = 507; // RFC 2518 10.6: Insufficient Storage    + //! Makes an HTTP request through a proxy. + .Query do_proxied_method(string|Standards.URI proxy, +  string user, string password, +  string method, +  string|Standards.URI url, +  void|mapping(string:int|string|array(string)) query_variables, +  void|mapping(string:string|array(string)) request_headers, +  void|Protocols.HTTP.Query con, void|string data) + { +  if( stringp(proxy) ) +  proxy = Standards.URI(proxy); +  if( stringp(url) ) +  url = Standards.URI(url); +  if( url->scheme != "http" ) error("No can do.\n"); +  +  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; +  url->query = 0; +  url->path = web_url; +  +  +  if( user || password ) +  { +  if( !request_headers ) +  request_headers = ([]); +  request_headers["Proxy-Authorization"] = "Basic " +  + MIME.encode_base64(url->user + ":" + +  (url->password || "")); +  } +  +  return do_method(method, url, 0, request_headers, con, data); + } +    //! Low level HTTP call method.   //!   //! @param method   //! The HTTP method to use, e.g. @expr{"GET"@}.   //! @param url   //! The URL to perform @[method] on. Should be a complete URL,   //! including protocol, e.g. @expr{"https://pike.ida.liu.se/"@}.   //! @param query_variables   //! Calls @[http_encode_query] and appends the result to the URL.   //! @param request_headers