Skip to content
Snippets Groups Projects
Commit 06bdf637 authored by deuce's avatar deuce
Browse files

Fix use of global i variable.

Add Head method to do a HEAD request.
parent 50ad2eb6
No related branches found
No related tags found
No related merge requests found
......@@ -75,6 +75,8 @@ function HTTPRequest(username,password)
};
this.SendRequest=function() {
var i;
if((this.sock=new Socket(SOCK_STREAM))==null)
throw("Unable to create socket");
if(!this.sock.connect(this.url.host, this.url.port?this.url.port:(this.url.scheme=='http'?80:443))) {
......@@ -170,4 +172,25 @@ function HTTPRequest(username,password)
this.ReadResponse();
return(this.body);
};
this.Head=function(url, referer, base) {
var i;
var m;
var ret={};
this.SetupGet(url,referer,base);
this.request = this.request.replace(/^GET/, 'HEAD');
this.BasicAuth();
this.SendRequest();
this.ReadResponse();
for(i in this.response_headers) {
m = this.response_headers[i].match(/^(.*?):\s*(.*?)\s*$/);
if (m) {
if (ret[m[1]] == undefined)
ret[m[1]] = [];
ret[m[1]].push(m[2]);
}
}
return(ret);
};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment