Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,27 @@ added: v0.4.0

* {string} The request path.

### `request.method`
<!-- YAML
added: v0.4.0
-->

* {string} The request method.

### `request.host`
<!-- YAML
added: v0.4.0
Comment thread
zhangwinning marked this conversation as resolved.
Outdated
-->

* {string} The request host.

### `request.protocol`
<!-- YAML
added: v0.4.0
-->

* {string} The request protocol.

### `request.removeHeader(name)`
<!-- YAML
added: v1.6.0
Expand Down
2 changes: 2 additions & 0 deletions lib/_http_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ function ClientRequest(input, options, cb) {
this.parser = null;
this.maxHeadersCount = null;
this.reusedSocket = false;
this.host = host;
this.protocol = protocol;

let called = false;

Expand Down
25 changes: 25 additions & 0 deletions test/parallel/test-http-outgoing-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,28 @@ const OutgoingMessage = http.OutgoingMessage;
msg.write('asd');
assert.strictEqual(msg.writableLength, 7);
}

{
const server = http.createServer(function(req, res) {
Comment thread
zhangwinning marked this conversation as resolved.
Outdated
res.end();
res.on('finish', () => {
server.close();
Comment thread
zhangwinning marked this conversation as resolved.
Outdated
});
});

server.listen(0);

server.on('listening', function() {
Comment thread
zhangwinning marked this conversation as resolved.
Outdated
const req = http.request({
port: server.address().port,
method: 'GET',
path: '/'
});

assert.strictEqual(req.path, '/');
assert.strictEqual(req.method, 'GET');
assert.strictEqual(req.host, 'localhost');
assert.strictEqual(req.protocol, 'http:');
req.end();
});
}