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

version» Context lines:

pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:77:   //! the value to 0 will remove that header from the request.   //! @param con   //! Old connection object.   //! @param data   //! Data payload to be transmitted in the request.   //!   //! @seealso   //! @[do_sync_method()]   .Query do_method(string method,    string|Standards.URI url, -  void|mapping(string:int|string) query_variables, +  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(url))    url=Standards.URI(url);       if( (< "httpu", "httpmu" >)[url->scheme] ) {    return do_udp_method(method, url, query_variables, request_headers,    con, data);    }
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:143:       if (!con->ok) {    if (con->errno)    error ("I/O error: %s\n", strerror (con->errno));    return 0;    }    return con;   }      protected .Query do_udp_method(string method, Standards.URI url, -  void|mapping(string:int|string) query_variables, +  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(!request_headers)    request_headers = ([]);       string path = url->path;    if(path=="") {    if(url->method=="httpmu")
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:212:   //! Previously initialized connection object.   //! In particular the callbacks must have been set   //! (@[Query.set_callbacks()]).   //! @param data   //! Data payload to be transmitted in the request.   //!   //! @seealso   //! @[do_method()], @[Query.set_callbacks()]   void do_async_method(string method,    string|Standards.URI url, -  void|mapping(string:int|string) query_variables, +  void|mapping(string:int|string|array(string)) query_variables,    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");    }   
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:293:   }      //! 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   //! @expr{request_headers->Connection=="Keep-Alive"@} from a previous   //! request is provided and the already established server connection   //! can be used for the next request, you may gain some performance.   //!   .Query get_url(string|Standards.URI url, -  void|mapping(string:int|string) query_variables, +  void|mapping(string:int|string|array(string)) query_variables,    void|mapping(string:string|array(string)) request_headers,    void|Protocols.HTTP.Query con)   {    return do_method("GET", url, query_variables, request_headers, con);   }      //! Sends a HTTP PUT 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   //! @expr{request_headers->Connection=="Keep-Alive"@} from a previous   //! request is provided and the already established server connection   //! can be used for the next request, you may gain some performance.   //!   .Query put_url(string|Standards.URI url,    void|string file, -  void|mapping(string:int|string) query_variables, +  void|mapping(string:int|string|array(string)) query_variables,    void|mapping(string:string|array(string)) request_headers,    void|Protocols.HTTP.Query con)   {    return do_method("PUT", url, query_variables, request_headers, con, file);   }      //! Sends a HTTP DELETE 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   //! @expr{request_headers->Connection=="Keep-Alive"@} from a previous   //! request is provided and the already established server connection   //! can be used for the next request, you may gain some performance.   //!   .Query delete_url(string|Standards.URI url, -  void|mapping(string:int|string) query_variables, +  void|mapping(string:int|string|array(string)) query_variables,    void|mapping(string:string|array(string)) request_headers,    void|Protocols.HTTP.Query con)   {    return do_method("DELETE", url, query_variables, request_headers, con);   }      //! Returns an array of @expr{({content_type, data})@} after calling   //! the requested server for the information. @expr{0@} is returned   //! upon failure. Redirects (HTTP 302) are automatically followed.   //!   array(string) get_url_nice(string|Standards.URI url, -  void|mapping(string:int|string) query_variables, +  void|mapping(string:int|string|array(string)) query_variables,    void|mapping(string:string|array(string)) request_headers,    void|Protocols.HTTP.Query con)   {    .Query c;    multiset seen = (<>);    do {    if(!url) return 0;    if(seen[url] || sizeof(seen)>1000) return 0;    seen[url]=1;    c = get_url(url, query_variables, request_headers, con);
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:358:    if(c->status==302) url = c->headers->location;    } while( c->status!=200 );    return ({ c->headers["content-type"], c->data() });   }      //! Returns the returned data after calling the requested server for   //! information through HTTP GET. @expr{0@} is returned upon failure.   //! Redirects (HTTP 302) are automatically followed.   //!   string get_url_data(string|Standards.URI url, -  void|mapping(string:int|string) query_variables, +  void|mapping(string:int|string|array(string)) query_variables,    void|mapping(string:string|array(string)) request_headers,    void|Protocols.HTTP.Query con)   {    array(string) z = get_url_nice(url, query_variables, request_headers, con);    return z && z[1];   }      //! Similar to @[get_url], except that query variables is sent as a   //! POST request instead of a GET request.   .Query post_url(string|Standards.URI url, -  mapping(string:int|string) query_variables, +  mapping(string:int|string|array(string)) query_variables,    void|mapping(string:string|array(string)) request_headers,    void|Protocols.HTTP.Query con)   {    return do_method("POST", url, 0,    (request_headers||([]))|    (["content-type":    "application/x-www-form-urlencoded"]),    con,    http_encode_query(query_variables));   }      //! Similar to @[get_url_nice], except that query variables is sent as   //! a POST request instead of a GET request.   array(string) post_url_nice(string|Standards.URI url, -  mapping(string:int|string) query_variables, +  mapping(string:int|string|array(string)) query_variables,    void|mapping(string:string|array(string)) request_headers,    void|Protocols.HTTP.Query con)   {    .Query c = post_url(url, query_variables, request_headers, con);    return c && ({ c->headers["content-type"], c->data() });   }      //! Similar to @[get_url_data], except that query variables is sent as   //! a POST request instead of a GET request.   string post_url_data(string|Standards.URI url, -  mapping(string:int|string) query_variables, +  mapping(string:int|string|array(string)) query_variables,    void|mapping(string:string|array(string)) request_headers,    void|Protocols.HTTP.Query con)   {    .Query z = post_url(url, query_variables, request_headers, con);    return z && z->data();   }      //! Encodes a query mapping to a string;   //! this protects odd - in http perspective - characters   //! like '&' and '#' and control characters,