Skip to content

Commit adbfa70

Browse files
committed
allow form.submit with url string param to use https
1 parent 158443d commit adbfa70

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

lib/form_data.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,8 @@ FormData.prototype.submit = function(params, cb) {
385385
options = populate({
386386
port: params.port,
387387
path: params.pathname,
388-
host: params.hostname
388+
host: params.hostname,
389+
protocol: params.protocol
389390
}, defaults);
390391

391392
// use custom params
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var http = require('http');
2+
var https = require('https');
3+
var common = require('../common');
4+
var assert = common.assert;
5+
var FormData = require(common.dir.lib + '/form_data');
6+
7+
/**
8+
* Test url parsing during submission
9+
*/
10+
11+
var req;
12+
var form = new FormData();
13+
form.append('field', 'value');
14+
15+
// Basic parsing
16+
req = form.submit('http://localhost:' + common.port + '/path', function() {});
17+
assert.strictEqual(req.path, '/path');
18+
assert.ok(req.agent instanceof http.Agent, 'req.agent instanceof http.Agent');
19+
assert.strictEqual(req.getHeader('Host'), 'localhost:' + common.port);
20+
req.abort();
21+
22+
// HTTPS protocol handling
23+
req = form.submit('https://localhost:' + common.port + '/path', function() {});
24+
assert.ok(req.agent instanceof https.Agent, 'req.agent instanceof https.Agent');
25+
req.abort();
26+
27+

0 commit comments

Comments
 (0)