diff --git a/lib/client.js b/lib/client.js
index <HASH>..<HASH> 100644
--- a/lib/client.js
+++ b/lib/client.js
@@ -85,6 +85,10 @@ WebSocket.prototype._connect = function() {
 
 	this.state = WS13.State.Connecting;
 
+	if (this.options.handshakeBody) {
+		this.headers['content-length'] = this.options.handshakeBody.length;
+	}
+
 	this._connectOptions.headers = this.headers;
 	this._connectOptions.agent = false;
 
@@ -92,7 +96,6 @@ WebSocket.prototype._connect = function() {
 		var serverHttpVersion = res.httpVersion;
 		var responseCode = res.statusCode;
 		var responseText = res.statusMessage;
-		var headers = res.headers;
 
 		var err = new Error();
 		err.responseCode = responseCode;
@@ -204,7 +207,7 @@ WebSocket.prototype._connect = function() {
 		this.emit('error', err);
 	});
 
-	req.end();
+	req.end(this.options.handshakeBody);
 };
 
 WebSocket.prototype._sendFrame = function(frame) {
Added ability to send body in handshake