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

doc, test: add note to response.getHeaders #12887

Closed
wants to merge 0 commits into from

Conversation

@refack
Copy link
Member

commented May 7, 2017

  • also correct language for the same note for querystring.parse
  • add assertions for said note

Fixes: #12885
Ref: #12883

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

test,doc

@refack refack requested a review from mscdex May 7, 2017

@refack refack self-assigned this May 7, 2017

@refack refack added doc http test labels May 7, 2017

@refack

This comment has been minimized.

Copy link
Member Author

commented May 7, 2017

doc/api/querystring.md Outdated
prototypically extend from the JavaScript `Object`. This means that the
typical `Object` methods such as `obj.toString()`, `obj.hasOwnProperty()`,
and others are not defined and *will not work*.
prototypically extend the JavaScript `Object`. This means that typical`Object`

This comment has been minimized.

Copy link
@addaleax

addaleax May 7, 2017

Member

typo: space after typical

doc/api/querystring.md Outdated
and others are not defined and *will not work*.
prototypically extend the JavaScript `Object`. This means that typical`Object`
methods such as `obj.toString()`, `obj.hasOwnProperty()`, and others are not
defined and *will not work*. As well `obj instanceof Object === false`.

This comment has been minimized.

Copy link
@addaleax

addaleax May 7, 2017

Member

Can you try to use complete sentences in the documentation? Also, this isn’t that simple anyway. Other Contexts can have different Object objects anyway – the better advice is to avoid instanceof for builtins in JS code (i.e. please drop the last sentence here).

This comment has been minimized.

Copy link
@refack

refack May 7, 2017

Author Member

Reasonable 👍

doc/api/http.md Outdated
@@ -974,7 +974,11 @@ const headerNames = response.getHeaderNames();
added: v7.7.0
-->

* Returns: {Object}
* Returns: {Object}
*Note*: The object returned by the `response.getHeaders()` method _does not_

This comment has been minimized.

Copy link
@addaleax

addaleax May 7, 2017

Member

Can you put this note at the end of the documentation section?

This comment has been minimized.

Copy link
@refack

refack May 7, 2017

Author Member

Only difference is that there there is no explicit * Returns: {Object}

doc/api/http.md Outdated
@@ -1,4 +1,4 @@
# HTTP
# HTTP

This comment has been minimized.

Copy link
@TimothyGu

TimothyGu May 7, 2017

Member

What's going on with this hunk?

This comment has been minimized.

Copy link
@refack

refack May 7, 2017

Author Member

I don't know, reverting

This comment has been minimized.

Copy link
@refack

refack May 7, 2017

Author Member

There's a weird space at line 559 that made my editor decide it's a UTF-8 file, and added the BOM.

This comment has been minimized.

Copy link
@TimothyGu

TimothyGu May 7, 2017

Member

You mean UTF-16?

This comment has been minimized.

Copy link
@refack
doc/api/http.md Outdated
@@ -974,7 +974,11 @@ const headerNames = response.getHeaderNames();
added: v7.7.0
-->

* Returns: {Object}
* Returns: {Object}
*Note*: The object returned by the `response.getHeaders()` method _does not_

This comment has been minimized.

Copy link
@TimothyGu

TimothyGu May 7, 2017

Member

Can you put the note in the prose like querystring.parse()?

doc/api/http.md Outdated
* Returns: {Object}
* Returns: {Object}
*Note*: The object returned by the `response.getHeaders()` method _does not_
prototypically extend the JavaScript `Object`. This means that typical`Object`

This comment has been minimized.

Copy link
@TimothyGu

TimothyGu May 7, 2017

Member

Missing space between "typical" and "Object"

doc/api/http.md Outdated
*Note*: The object returned by the `response.getHeaders()` method _does not_
prototypically extend the JavaScript `Object`. This means that typical`Object`
methods such as `obj.toString()`, `obj.hasOwnProperty()`, and others are not
defined and *will not work*. As well `obj instanceof Object === false`.

This comment has been minimized.

Copy link
@TimothyGu

TimothyGu May 7, 2017

Member

Either make the last bit a complete sentence, or fold it into the previous sentence.

This comment has been minimized.

Copy link
@refack

refack May 7, 2017

Author Member

Removing.

test/parallel/test-http-mutable-headers.js Outdated
// eslint-disable-next-line no-restricted-properties
assert.deepEqual(res.getHeaders(), {});
assert.deepEqual(headers, {});

This comment has been minimized.

Copy link
@TimothyGu

TimothyGu May 7, 2017

Member

deepStrictEqual while at it?

This comment has been minimized.

Copy link
@refack

refack May 7, 2017

Author Member

Need to remove prototype from {}, but why not...

@refack refack force-pushed the refack:fix-12885-change-doc branch May 7, 2017

@refack

This comment has been minimized.

Copy link
Member Author

commented May 7, 2017

Addressed. PTAL.

@refack

This comment has been minimized.

Copy link
Member Author

commented May 7, 2017

doc/api/http.md Outdated
@@ -982,6 +982,11 @@ header-related http module methods. The keys of the returned object are the
header names and the values are the respective header values. All header names
are lowercase.

*Note*: The object returned by the `response.getHeaders()` method _does not_
prototypically extend the JavaScript `Object`. This means that typical`Object`

This comment has been minimized.

Copy link
@addaleax

addaleax May 7, 2017

Member

still a missing space after “typical”

This comment has been minimized.

Copy link
@refack

refack May 7, 2017

Author Member

Ack

doc/api/http.md Outdated
@@ -982,6 +982,11 @@ header-related http module methods. The keys of the returned object are the
header names and the values are the respective header values. All header names
are lowercase.

*Note*: The object returned by the `response.getHeaders()` method _does not_
prototypically extend the JavaScript `Object`. This means that typical`Object`

This comment has been minimized.

Copy link
@TimothyGu

TimothyGu May 7, 2017

Member

Still missing a space.

test/parallel/test-http-mutable-headers.js Outdated
assert.deepEqual(res.getHeaders(), {});
const headers = res.getHeaders();
const objLike = Object.create(Object.getPrototypeOf(headers));
assert.deepStrictEqual(headers, objLike);

This comment has been minimized.

Copy link
@TimothyGu

TimothyGu May 7, 2017

Member

Why not just compare it to Object.create(null)?

This comment has been minimized.

Copy link
@refack

refack May 7, 2017

Author Member

Fails on 7.10 🤷‍♂️

This comment has been minimized.

Copy link
@refack

refack May 7, 2017

Author Member

Changed.
(Well the test fails anyway in other places on 7.10)

@refack refack force-pushed the refack:fix-12885-change-doc branch 2 times, most recently May 7, 2017

@addaleax
Copy link
Member

left a comment

Looks good, but the old querystring.md wording sounded a bit clearer to me.

@lpinca
lpinca approved these changes May 7, 2017
@refack

This comment has been minimized.

Copy link
Member Author

commented May 7, 2017

/cc @nodejs/documentation comments about the wording?

doc/api/http.md Outdated
@@ -982,6 +982,11 @@ header-related http module methods. The keys of the returned object are the
header names and the values are the respective header values. All header names
are lowercase.

*Note*: The object returned by the `response.getHeaders()` method _does not_
prototypically extend the JavaScript `Object`. This means that typical `Object`

This comment has been minimized.

Copy link
@mscdex

mscdex May 7, 2017

Contributor

s/extend the/inherit from the/

doc/api/http.md Outdated
@@ -556,7 +556,7 @@ Returns `request`.
added: v0.1.17
-->

This class inherits from [`net.Server`][] and has the following additional events:
Thisclass inherits from [`net.Server`][] and has the following additional events:

This comment has been minimized.

Copy link
@thefourtheye

thefourtheye May 8, 2017

Contributor

Just to be sure, the extra whitespace at the end of this line has been removed, right?

This comment has been minimized.

Copy link
@refack

refack May 8, 2017

Author Member

There's a Unicode white space there, that I converted to \u0020. I'll make sure that it's right

This comment has been minimized.

Copy link
@refack

refack May 8, 2017

Author Member

There was a \0x00A0 at position 5 I replaced with \u0020. I verified with a hex compare.

test/parallel/test-http-mutable-headers.js Outdated
// eslint-disable-next-line no-restricted-properties
assert.deepEqual(res.getHeaders(), {});
const headers = res.getHeaders();
const objLike = Object.create(null);

This comment has been minimized.

Copy link
@thefourtheye

thefourtheye May 8, 2017

Contributor

Nit: This is an object, not object like :D

This comment has been minimized.

Copy link
@refack

refack May 8, 2017

Author Member

I had this discussion with @addaleax. How can it be an Object if objLike instaceof Object === false ?
According to OOP definitions "not" objLike is an Object. It's actually a null with properies 😉

This comment has been minimized.

Copy link
@refack

refack May 8, 2017

Author Member

I could call it sonOfNull...

This comment has been minimized.

Copy link
@mscdex

mscdex May 8, 2017

Contributor

I agree with @thefourtheye, it's still an object according to the spec.

@refack refack force-pushed the refack:fix-12885-change-doc branch May 8, 2017

doc/api/http.md Outdated
@@ -556,7 +556,7 @@ Returns `request`.
added: v0.1.17
-->

This class inherits from [`net.Server`][] and has the following additional events:
This class inherits from [`net.Server`][] and has the following additional events:

This comment has been minimized.

Copy link
@refack

refack May 8, 2017

Author Member

replaced a \u00A0 with a \u0020, so now the document is ANSI and not UTF-8

This comment has been minimized.

Copy link
@addaleax

addaleax May 8, 2017

Member

@refack Just to be clear, our docs are UTF-8 and don’t need to be restricted to ASCII. This change is obviously fine, but it might be a good idea to tell your editor to not use BOMs for UTF-8.

doc/api/querystring.md Outdated
prototypically extend from the JavaScript `Object`. This means that the
typical `Object` methods such as `obj.toString()`, `obj.hasOwnProperty()`,
and others are not defined and *will not work*.
prototypically extend the JavaScript `Object`. This means that typical `Object`

This comment has been minimized.

Copy link
@mscdex

mscdex May 8, 2017

Contributor

s/extend the/inherit from the/

@refack refack force-pushed the refack:fix-12885-change-doc branch to f16669a May 8, 2017

// eslint-disable-next-line no-restricted-properties
assert.deepEqual(res.getHeaders(), {});
const headers = res.getHeaders();
const exoticObj = Object.create(null);

This comment has been minimized.

Copy link
@thefourtheye

thefourtheye May 8, 2017

Contributor

Nit: I am being extremely pedantic here. So please ignore this comment, if you don't agree. Quoting 9.1 Ordinary Object Internal Methods and Internal Slots,

All ordinary objects have an internal slot called [[Prototype]]. The value of this internal slot is either null or an object and is used for implementing inheritance.

This object doesn't do or posses anything exotic. So this is still a normal object I believe.

This comment has been minimized.

Copy link
@mscdex

mscdex May 8, 2017

Contributor

I agree with @thefourtheye. Probably better to call it something like simpleObj or bareObj or something similar without getting too wordy...

@refack refack closed this May 10, 2017

@refack refack force-pushed the refack:fix-12885-change-doc branch from f16669a to e1cabf6 May 10, 2017

refack added a commit to refack/node that referenced this pull request May 10, 2017
doc, test: add note to response.getHeaders
* also correct language for the same note for querystring.parse
* add assertions for said note

PR-URL: nodejs#12887
Fixes: nodejs#12885
Refs: nodejs#12883
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
@refack

This comment has been minimized.

Copy link
Member Author

commented May 10, 2017

landed in e1cabf6

@refack refack deleted the refack:fix-12885-change-doc branch May 10, 2017

@refack

This comment has been minimized.

Copy link
Member Author

commented May 10, 2017

@mscdex

This comment has been minimized.

Copy link
Contributor

commented May 10, 2017

@refack I think you left that CI comment on the wrong PR? That CI run is for this commit: "test: use assert regexp in tls no cert test"

@refack

This comment has been minimized.

Copy link
Member Author

commented May 10, 2017

@refack I think you left that CI comment on the wrong PR? That CI run is for this commit: "test: use assert regexp in tls no cert test"

Since the CI is on master the one CI job covers three small lands I did almost together.

anchnk pushed a commit to anchnk/node that referenced this pull request May 19, 2017
doc, test: add note to response.getHeaders
* also correct language for the same note for querystring.parse
* add assertions for said note

PR-URL: nodejs#12887
Fixes: nodejs#12885
Refs: nodejs#12883
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
@jasnell jasnell referenced this pull request May 28, 2017

@refack refack removed their assignment Jun 12, 2017

@gibfahn gibfahn referenced this pull request Jun 15, 2017
2 of 3 tasks complete
@gibfahn

This comment has been minimized.

Copy link
Member

commented Jun 20, 2017

Should this be backported to v6.x-staging? If yes please follow the guide and raise a backport PR, if no let me know or add the dont-land-on label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.