@@ -24,7 +24,6 @@ exports.XMLHttpRequest = function() {
2424 var https = require ( 'https' ) ;
2525
2626 // Holds http.js objects
27- var client ;
2827 var request ;
2928 var response ;
3029
@@ -154,7 +153,6 @@ exports.XMLHttpRequest = function() {
154153 // Check for valid request method
155154 if ( ! isAllowedHttpMethod ( method ) ) {
156155 throw "SecurityError: Request method not allowed" ;
157- return ;
158156 }
159157
160158 settings = {
@@ -267,14 +265,14 @@ exports.XMLHttpRequest = function() {
267265
268266 var ssl = false , local = false ;
269267 var url = Url . parse ( settings . url ) ;
270-
268+ var host ;
271269 // Determine the server
272270 switch ( url . protocol ) {
273271 case 'https:' :
274272 ssl = true ;
275273 // SSL & non-SSL both need host, no break here.
276274 case 'http:' :
277- var host = url . hostname ;
275+ host = url . hostname ;
278276 break ;
279277
280278 case 'file:' :
@@ -283,7 +281,7 @@ exports.XMLHttpRequest = function() {
283281
284282 case undefined :
285283 case '' :
286- var host = "localhost" ;
284+ host = "localhost" ;
287285 break ;
288286
289287 default :
@@ -344,7 +342,7 @@ exports.XMLHttpRequest = function() {
344342 if ( settings . method === "GET" || settings . method === "HEAD" ) {
345343 data = null ;
346344 } else if ( data ) {
347- headers [ "Content-Length" ] = Buffer . byteLength ( data ) ;
345+ headers [ "Content-Length" ] = Buffer . isBuffer ( data ) ? data . length : Buffer . byteLength ( data ) ;
348346
349347 if ( ! headers [ "Content-Type" ] ) {
350348 headers [ "Content-Type" ] = "text/plain;charset=UTF-8" ;
@@ -478,7 +476,7 @@ exports.XMLHttpRequest = function() {
478476 + ( data ? "req.write('" + data . replace ( / ' / g, "\\'" ) + "');" :"" )
479477 + "req.end();" ;
480478 // Start the other Node Process, executing this string
481- syncProc = spawn ( process . argv [ 0 ] , [ "-e" , execString ] ) ;
479+ var syncProc = spawn ( process . argv [ 0 ] , [ "-e" , execString ] ) ;
482480 while ( ( self . responseText = fs . readFileSync ( syncFile , 'utf8' ) ) == "" ) {
483481 // Wait while the file is empty
484482 }
0 commit comments