Skip to content

Commit 5847424

Browse files
committed
Fixed code styling.
1 parent c406ac9 commit 5847424

5 files changed

Lines changed: 26 additions & 40 deletions

File tree

Readme.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ var http = require('http');
3535

3636
var form = new FormData();
3737

38-
http.request('http://nodejs.org/images/logo.png', function(response)
39-
{
38+
http.request('http://nodejs.org/images/logo.png', function(response) {
4039
form.append('my_field', 'my value');
4140
form.append('my_buffer', new Buffer(10));
4241
form.append('my_logo', response);

lib/form_data.js

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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

test/integration/test-http-response.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@ var FIELDS;
1515
var server;
1616

1717
var parsedUrl = parseUrl(remoteFile)
18-
, options =
19-
{
18+
, options = {
2019
method: 'get',
2120
port: parsedUrl.port || 80,
2221
path: parsedUrl.pathname,
2322
host: parsedUrl.hostname
2423
}
2524
;
2625

27-
http.request(options, function(res)
28-
{
26+
http.request(options, function(res) {
2927

3028
FIELDS = [
3129
{name: 'my_field', value: 'my_value'},
@@ -83,12 +81,12 @@ server = http.createServer(function(req, res) {
8381
// temp workaround
8482
var data = '';
8583
req.setEncoding('utf8');
86-
req.on('data', function(d)
87-
{
84+
85+
req.on('data', function(d) {
8886
data += d;
8987
});
90-
req.on('end', function()
91-
{
88+
89+
req.on('end', function() {
9290

9391
// check for the fields' traces
9492

test/integration/test-pipe.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ var server = http.createServer(function(req, res) {
4444
// temp workaround
4545
var data = '';
4646
req.setEncoding('utf8');
47-
req.on('data', function(d)
48-
{
47+
48+
req.on('data', function(d) {
4949
data += d;
5050
});
51-
req.on('end', function()
52-
{
51+
52+
req.on('end', function() {
5353
// check for the fields' traces
5454

5555
// 1st field : my_field

test/integration/test-submit.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,10 @@ var server = http.createServer(function(req, res) {
4545
// temp workaround
4646
var data = '';
4747
req.setEncoding('utf8');
48-
req.on('data', function(d)
49-
{
48+
req.on('data', function(d) {
5049
data += d;
5150
});
52-
req.on('end', function()
53-
{
51+
req.on('end', function() {
5452
// check for the fields' traces
5553

5654
// 1st field : my_field

0 commit comments

Comments
 (0)