@@ -57,8 +57,7 @@ FormData.prototype._trackLength = function(header, value) {
5757 this . _lengthRetrievers . push ( function ( next ) {
5858
5959 // check if it's local file
60- if ( value . hasOwnProperty ( 'fd' ) )
61- {
60+ if ( value . hasOwnProperty ( 'fd' ) ) {
6261 fs . stat ( value . path , function ( err , stat ) {
6362 if ( err ) {
6463 next ( err ) ;
@@ -67,26 +66,22 @@ FormData.prototype._trackLength = function(header, value) {
6766
6867 next ( null , stat . size ) ;
6968 } ) ;
70- }
69+
7170 // or http response
72- else if ( value . hasOwnProperty ( 'httpVersion' ) )
73- {
71+ } else if ( value . hasOwnProperty ( 'httpVersion' ) ) {
7472 next ( null , + value . headers [ 'content-length' ] ) ;
75- }
73+
7674 // or request stream http://github.com/mikeal/request
77- else if ( value . hasOwnProperty ( 'httpModule' ) )
78- {
75+ } else if ( value . hasOwnProperty ( 'httpModule' ) ) {
7976 // wait till response come back
80- value . on ( 'response' , function ( response )
81- {
77+ value . on ( 'response' , function ( response ) {
8278 value . pause ( ) ;
8379 next ( null , + response . headers [ 'content-length' ] ) ;
8480 } ) ;
8581 value . resume ( ) ;
86- }
87- else
88- {
89- // something else
82+
83+ // something else
84+ } else {
9085 next ( 'Unknown stream' ) ;
9186 }
9287 } ) ;
@@ -104,10 +99,9 @@ FormData.prototype._multiPartHeader = function(field, value) {
10499 header +=
105100 '; filename="' + path . basename ( value . path ) + '"' + FormData . LINE_BREAK +
106101 'Content-Type: ' + mime . lookup ( value . path ) ;
107- }
102+
108103 // http response has not
109- else if ( value . readable && value . hasOwnProperty ( 'httpVersion' ) )
110- {
104+ } else if ( value . readable && value . hasOwnProperty ( 'httpVersion' ) ) {
111105 header +=
112106 '; filename="' + path . basename ( value . client . _httpMessage . path ) + '"' + FormData . LINE_BREAK +
113107 'Content-Type: ' + value . headers [ 'content-type' ] ;
@@ -224,14 +218,11 @@ FormData.prototype.submit = function(url, cb) {
224218 host : parsedUrl . hostname
225219 } ;
226220
227- if ( parsedUrl . protocol == 'https:' )
228- {
221+ if ( parsedUrl . protocol == 'https:' ) {
229222 // override default port
230223 if ( ! parsedUrl . port ) options . port = 443 ;
231224 request = https . request ( options ) ;
232- }
233- else
234- {
225+ } else {
235226 request = http . request ( options ) ;
236227 }
237228
0 commit comments