From 06bdf637f2be551f10ff724e008463680c0201c6 Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Wed, 6 May 2015 02:08:44 +0000
Subject: [PATCH] Fix use of global i variable. Add Head method to do a HEAD
 request.

---
 exec/load/http.js | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/exec/load/http.js b/exec/load/http.js
index a4e11fbd7f..1256f3dcd4 100644
--- a/exec/load/http.js
+++ b/exec/load/http.js
@@ -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);
+	};
 }
-- 
GitLab