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

version» Context lines:

pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:82:   .Query do_method(string method,    string|Standards.URI url,    void|mapping(string:int|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] ) { -  do_udp_method(method, url, query_variables, request_headers, data); -  return 0; +  return do_udp_method(method, url, query_variables, request_headers, data);    }       if(!con)    con = .Query();      #if constant(SSL.sslfile)    if(url->scheme!="http" && url->scheme!="https")    error("Can't handle %O or any other protocols than HTTP or HTTPS.\n",    url->scheme);   
pike.git/lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:139:    request_headers, data);       if (!con->ok) {    if (con->errno)    error ("I/O error: %s\n", strerror (con->errno));    return 0;    }    return con;   }    - static void do_udp_method(string method, Standards.URI url, + static .Query do_udp_method(string method, Standards.URI url,    void|mapping(string:int|string) query_variables,    void|mapping(string:string|array(string))    request_headers, void|Stdio.UDP udp,    void|string data)   {    if(!request_headers)    request_headers = ([]);       string path = url->path;    if(path=="") {    if(url->method=="httpmu")    path = "*";    else    path = "/";    }    string msg = method + " " + path + " HTTP/1.1\r\n";    if(!udp) {    udp = Stdio.UDP();    int port = 10000 + random(1000); -  while( catch( udp->bind(port++) ) ); +  int i; +  while(1) { +  if( !catch( udp->bind(port++) ) ) break; +  if( i++ > 1000 ) error("Could not open a UDP port.\n"); +  }    if(url->method=="httpmu") { -  udp->enable_multicast("130.236.182.86"); +  mapping ifs = Stdio.gethostip(); +  if(!sizeof(ifs)) error("No Internet interface found.\n"); +  foreach(ifs; string i; mapping data) +  if(sizeof(data->ips)) { +  udp->enable_multicast(data->ips[0]); +  break; +  }    udp->add_membership(url->host, 0, 0);    }    udp->set_multicast_ttl(4);    }    udp->send(url->host, url->port, msg); -  +  .Query q=.Query(); +  q->con = udp; +  return q;   }      //! 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,