Branch: Tag:

2005-01-24

2005-01-24 22:50:34 by Martin Nilsson <mani@lysator.liu.se>

Improved and generalized httpu/httpmu support

Rev: lib/modules/Protocols.pmod/HTTP.pmod/module.pmod:1.50

89:    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)
146:    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,
166:    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