Skip to content

Commit 4043fbb

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

2 files changed

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

0 commit comments

Comments
 (0)