Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http request with header "constructor" results to a value of "function Object() { [native code] }, " #4456

Closed
ravenjohn opened this issue Dec 28, 2015 · 2 comments
Labels
http Issues or PRs related to the http subsystem.

Comments

@ravenjohn
Copy link

I'm using Node v5.3.0 on Windows 10. I was playing with http and found out that a request with a header name constructor results to function Object() { [native code] },

Simple HTTP Server

const http = require('http');

http.createServer((request, response) => {
        response.end(JSON.stringify(request.headers, null, '\t'));
    })
    .listen(8000);

Request

const net = require('net');
const client = new net.Socket();

client.connect(8000, '127.0.0.1', () => {
    client.write('GET / HTTP/1.1\r\nconstructor:\r\n\r\n');
});

client.on('data', (data) => {
    console.log(data.toString());
    client.destroy();
});

client.on('close', function() {
    console.log('Connection closed');
});

Output

HTTP/1.1 200 OK
Date: Mon, 28 Dec 2015 21:17:55 GMT
Connection: keep-alive
Content-Length: 59

{
        "constructor": "function Object() { [native code] }, "
}
Connection closed
@mscdex mscdex added the http Issues or PRs related to the http subsystem. label Dec 28, 2015
@mscdex
Copy link
Contributor

mscdex commented Dec 28, 2015

I've got a patch to fix this coming soon...

mscdex added a commit to mscdex/io.js that referenced this issue Dec 28, 2015
Since headers are stored in an empty literal object ({}) instead
of an object created with Object.create(null), care must be taken
with property names inherited from Object. Currently there are
only functions inherited, so we can safely check for existing
strings instead.

Fixes: nodejs#4456
@ravenjohn
Copy link
Author

Cool!

@mscdex mscdex closed this as completed in 2a1ef97 Dec 30, 2015
Fishrock123 pushed a commit to Fishrock123/node that referenced this issue Jan 6, 2016
Since headers are stored in an empty literal object ({}) instead
of an object created with Object.create(null), care must be taken
with property names inherited from Object. Currently there are
only functions inherited, so we can safely check for existing
strings instead.

Fixes: nodejs#4456
PR-URL: nodejs#4460
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
MylesBorins pushed a commit that referenced this issue Jan 28, 2016
Since headers are stored in an empty literal object ({}) instead
of an object created with Object.create(null), care must be taken
with property names inherited from Object. Currently there are
only functions inherited, so we can safely check for existing
strings instead.

Fixes: #4456
PR-URL: #4460
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
MylesBorins pushed a commit that referenced this issue Feb 11, 2016
Since headers are stored in an empty literal object ({}) instead
of an object created with Object.create(null), care must be taken
with property names inherited from Object. Currently there are
only functions inherited, so we can safely check for existing
strings instead.

Fixes: #4456
PR-URL: #4460
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
MylesBorins pushed a commit to MylesBorins/node that referenced this issue Feb 11, 2016
Since headers are stored in an empty literal object ({}) instead
of an object created with Object.create(null), care must be taken
with property names inherited from Object. Currently there are
only functions inherited, so we can safely check for existing
strings instead.

Fixes: nodejs#4456
PR-URL: nodejs#4460
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
MylesBorins pushed a commit to MylesBorins/node that referenced this issue Feb 15, 2016
Since headers are stored in an empty literal object ({}) instead
of an object created with Object.create(null), care must be taken
with property names inherited from Object. Currently there are
only functions inherited, so we can safely check for existing
strings instead.

Fixes: nodejs#4456
PR-URL: nodejs#4460
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
scovetta pushed a commit to scovetta/node that referenced this issue Apr 2, 2016
Since headers are stored in an empty literal object ({}) instead
of an object created with Object.create(null), care must be taken
with property names inherited from Object. Currently there are
only functions inherited, so we can safely check for existing
strings instead.

Fixes: nodejs#4456
PR-URL: nodejs#4460
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem.
Projects
None yet
Development

No branches or pull requests

2 participants