Branch: Tag:

2001-01-31

2001-01-31 17:38:04 by Johan Sundström <oyasumi@gmail.com>

Protocols.HTTP now supports basic auth, extracting user:password from
the authority part of a URL, when such were stated.

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

70:    if(!con)    con = Protocols.HTTP.Query();    -  if(!request_headers) -  request_headers = ([]); -  +     if(stringp(url))    url=Standards.URI(url);   
80:    error("Protocols.HTTP can't handle %O or any other protocol than HTTP\n",    url->scheme);    +  if(!request_headers) +  request_headers = ([]); +  mapping default_headers = ([ +  "user-agent" : "Mozilla/4.0 compatible (Pike HTTP client)", +  "host" : url->host ]); +  if(url->user || url->passwd) +  default_headers->authorization = "Basic " +  + MIME.encode_base64(url->user + ":" + +  (url->password || "")); +  request_headers = default_headers | request_headers; +     string query=url->query;    if(query_variables && sizeof(query_variables))    {
94:       con->sync_request(url->host,url->port,    method+" "+path+(query?("?"+query):"")+" HTTP/1.0", -  ([ -  "user-agent":"Mozilla/4.0 compatible (Pike HTTP client)", -  "host":url->host -  ]) | request_headers, data); +  request_headers, data);       if (!con->ok) return 0;    return con;