Closed
Description
- Version: master
- Platform: n/a
- Subsystem: doc
The documentation for request.path
mentions that the property is read-only, which is misleading.
First, it is technically not set as a real read-only property, so it is mutable. Secondly, request.path
is read from at a later point in time if headers
was not passed to the ClientRequest
constructor.
Here is a small example that shows this:
const http = require('http');
http.createServer(function(req, res) {
this.close();
console.log('req.url =', req.url);
res.end();
}).listen(0, function() {
const req = http.request(
{ port: this.address().port, method: 'GET' },
(res) => res.resume()
);
console.log('req.path =', req.path);
req.path = '/foo/bar/baz';
req.end();
});
// prints:
// req.path = /
// req.url = /foo/bar/baz
I would suggest removing the 'Read-only' portion from the description or making the property truly read-only using the appropriate property descriptor.