GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — http: improves expect header handling by designfrontier · Pull Request #4501 · nodejs/node

Conversation

@designfrontier

@designfrontier designfrontier commented Dec 31, 2015

Copy link
Copy Markdown
Contributor

Now returns a 417 error status or allows for an event listener on
the checkExpectation event. Before we were ignoring requests that
had misspelled 100-continue values for expect headers.

This is a quick port of the work done here:
nodejs/node-v0.x-archive#7132 by alFReD-NSH
with surrounding discussion here:
nodejs/node-v0.x-archive#4651

Refs: #2403

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mscdex mscdex added the http Issues and PRs related to the http subsystem. label Dec 31, 2015
mscdex
mscdex reviewed Dec 31, 2015
View reviewed changes
Comment thread lib/_http_server.js Outdated

@mscdex mscdex Dec 31, 2015

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid the type-checking util.* functions in node core code.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@designfrontier designfrontier Dec 31, 2015

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks and done

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@designfrontier
designfrontier force-pushed the feature-improve-expectation-handling-http branch from ce42fcd to 25f7e6a Compare December 31, 2015 23:16
mscdex
mscdex reviewed Jan 1, 2016
View reviewed changes
Comment thread lib/_http_server.js Outdated

@mscdex mscdex Jan 1, 2016

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nit, but checking directly against undefined (req.headers.expect !== undefined) instead of using typeof is preferred, when compared to the rest of the code base.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@designfrontier designfrontier Jan 1, 2016

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the nit picks :-) should be fixed now

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@designfrontier
designfrontier force-pushed the feature-improve-expectation-handling-http branch from 25f7e6a to 2343cb2 Compare January 1, 2016 06:17
mscdex
mscdex reviewed Jan 1, 2016
View reviewed changes
Comment thread lib/_http_server.js Outdated

@mscdex mscdex Jan 1, 2016

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also while we're in here, EventEmitter.listenerCount() is deprecated, so we should just use self.listenerCount('checkContinue'); instead and similarly for the other event below.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@designfrontier designfrontier Jan 1, 2016

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mscdex There is one other use of the EventEmitter.listenerCount in the file. Should I update it as well, or just change it in this new code?

Not sure how tightly scoped y'all like to keep the PRs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@mscdex mscdex Jan 1, 2016

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I think that should be ok.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@designfrontier
designfrontier force-pushed the feature-improve-expectation-handling-http branch from 2343cb2 to 20db3fe Compare January 1, 2016 18:55
evanlucas
evanlucas reviewed Jan 4, 2016
View reviewed changes
Comment thread test/parallel/test-http-expect-handling.js Outdated

@evanlucas evanlucas Jan 4, 2016

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we generally try to avoid explicitly calling process.exit() in tests. Could you instead just close the server (which should make the process exit on it's own)?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@jasnell jasnell added the semver-minor PRs that contain new features and should be released in the next minor version. label Jan 4, 2016
@jasnell

jasnell commented Jan 4, 2016

Copy link
Copy Markdown
Member

Marking semver-minor due to the addition of the new event

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Jan 4, 2016

Copy link
Copy Markdown
Member

Generally LGTM but @evanlucas is correct about not calling process.exit() in the test. Once that's resolved this looks good.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@designfrontier

designfrontier commented Jan 4, 2016

Copy link
Copy Markdown
Contributor Author

I'll try and get that knocked out this evening or tomorrow morning. Thanks for the feedback

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@designfrontier
designfrontier force-pushed the feature-improve-expectation-handling-http branch 2 times, most recently from 99b615d to e7d2033 Compare January 6, 2016 14:53
@designfrontier

designfrontier commented Jan 7, 2016

Copy link
Copy Markdown
Contributor Author

This should be ready to rock and roll now. Tests have been rewritten to use server.close() and are more complete now :-)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Jan 7, 2016

Copy link
Copy Markdown
Member

CI: https://ci.nodejs.org/job/node-test-pull-request/1161/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mscdex

mscdex commented Jan 7, 2016

Copy link
Copy Markdown
Contributor

@designfrontier the linter is complaining.... looks like const EventEmitter = require('events'); needs to be removed from lib/_http_server.js now that it's no longer being used.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@designfrontier
http: improves expect header handling
810158c
Now returns a 417 error status or allows for an event listener on
the `checkExpectation` event. Before we were ignoring requests that
had misspelled `100-continue` values for expect headers.

This is a quick port of the work done here:
nodejs/node-v0.x-archive#7132 by alFReD-NSH
with surrounding discussion here:
nodejs/node-v0.x-archive#4651

Also updates all the instances of the deprecated
EventEmitter.listenerCount to the current self.listenerCount. Most
of these were in the new code ported over but there was another
legacy instance.

Refs: nodejs#2403
@designfrontier
designfrontier force-pushed the feature-improve-expectation-handling-http branch from e7d2033 to 810158c Compare January 8, 2016 05:53
@designfrontier

designfrontier commented Jan 8, 2016

Copy link
Copy Markdown
Contributor Author

whoops eslint was acting up for me in sublime apparently. Fixed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mscdex

mscdex commented Jan 8, 2016

Copy link
Copy Markdown
Contributor

I think the other CI test failure is unrelated, but here goes again: https://ci.nodejs.org/job/node-test-pull-request/1166/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@designfrontier

designfrontier commented Jan 12, 2016

Copy link
Copy Markdown
Contributor Author

Looks like it passed jenkins... anything else I need to do on this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Jan 12, 2016

Copy link
Copy Markdown
Member

LGTM @nodejs/http

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@dougwilson

dougwilson commented Jan 12, 2016

Copy link
Copy Markdown
Member

Seems OK

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell pushed a commit that referenced this pull request Jan 13, 2016
@designfrontier @jasnell
http: improves expect header handling
d755432
Now returns a 417 error status or allows for an event listener on
the `checkExpectation` event. Before we were ignoring requests that
had misspelled `100-continue` values for expect headers.

This is a quick port of the work done here:
nodejs/node-v0.x-archive#7132 by alFReD-NSH
with surrounding discussion here:
nodejs/node-v0.x-archive#4651

Also updates all the instances of the deprecated
EventEmitter.listenerCount to the current self.listenerCount. Most
of these were in the new code ported over but there was another
legacy instance.

Refs: #2403
PR-URL: #4501
Reviewed-By: James M Snell <[email protected]>
@jasnell

jasnell commented Jan 13, 2016

Copy link
Copy Markdown
Member

Landed in d755432

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell jasnell closed this Jan 13, 2016
@rvagg

rvagg commented Jan 18, 2016

Copy link
Copy Markdown
Member

Nice work @designfrontier! I believe this is your first commit in to core, if so, welcome on board! I hope you stick around and find other ways to contribute.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@designfrontier

designfrontier commented Jan 18, 2016

Copy link
Copy Markdown
Contributor Author

It is! I plan to stick around and keep grabbing ticket when I have spare
time :-)
On Sun, Jan 17, 2016 at 7:42 PM Rod Vagg [email protected] wrote:

Nice work @designfrontier https://github.com/designfrontier! I believe
this is your first commit in to core, if so, welcome on board! I hope you
stick around and find other ways to contribute.

—
Reply to this email directly or view it on GitHub
#4501 (comment).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@evanlucas evanlucas mentioned this pull request Jan 18, 2016
v5.5.0 Release Proposal (Stable) #4742
Merged
evanlucas pushed a commit that referenced this pull request Jan 18, 2016
@designfrontier @evanlucas
http: improves expect header handling
c171294
Now returns a 417 error status or allows for an event listener on
the `checkExpectation` event. Before we were ignoring requests that
had misspelled `100-continue` values for expect headers.

This is a quick port of the work done here:
nodejs/node-v0.x-archive#7132 by alFReD-NSH
with surrounding discussion here:
nodejs/node-v0.x-archive#4651

Also updates all the instances of the deprecated
EventEmitter.listenerCount to the current self.listenerCount. Most
of these were in the new code ported over but there was another
legacy instance.

Refs: #2403
PR-URL: #4501
Reviewed-By: James M Snell <[email protected]>
@evanlucas evanlucas mentioned this pull request Jan 20, 2016
http: improving expectation handling #2403
Closed
evanlucas added a commit that referenced this pull request Jan 20, 2016
@evanlucas
2016-01-20, Version 5.5.0 (Stable)
dd88256
Notable changes:

* events: make sure console functions exist (Dave) #4479
* fs: add autoClose option to fs.createWriteStream (Saquib) #3679
* http: improves expect header handling (Daniel Sellers) #4501
* node: allow preload modules with -i (Evan Lucas) #4696
* v8,src: expose statistics about heap spaces (`v8.getHeapSpaceStatistics()`) (Ben Ripkens) #4463
* Minor performance improvements:
  - lib: Use arrow functions instead of bind where possible (Minwoo Jung) #3622
  - module: cache stat() results more aggressively (Ben Noordhuis) #4575
  - querystring: improve parse() performance (Brian White) #4675

PR-URL: #4742
evanlucas added a commit that referenced this pull request Jan 21, 2016
@evanlucas
2016-01-20, Version 5.5.0 (Stable)
318ded2
Notable changes:

* events: make sure console functions exist (Dave) #4479
* fs: add autoClose option to fs.createWriteStream (Saquib) #3679
* http: improves expect header handling (Daniel Sellers) #4501
* node: allow preload modules with -i (Evan Lucas) #4696
* v8,src: expose statistics about heap spaces (`v8.getHeapSpaceStatistics()`) (Ben Ripkens) #4463
* Minor performance improvements:
  - lib: Use arrow functions instead of bind where possible (Minwoo Jung) #3622
  - module: cache stat() results more aggressively (Ben Noordhuis) #4575
  - querystring: improve parse() performance (Brian White) #4675

PR-URL: #4742
mbland pushed a commit to 18F/pages-server that referenced this pull request Feb 1, 2016
Mike Bland
Fix HTTP 417 error when testing with Node v5.5.0
6285056
In Node v5.5.0, the HTTP server became more diligent about sending a HTTP 417
Expectation Failed response if the `Expect` header was not `100-continue`.
Since `RequestHelper.httpOptions` was creating requests with an empty `Expect`
header, and did not define a `checkExpectation` event handler, the server
returned 417 errors for these requests.

Also updated `RequestHelper.sendRequest` to use the status code text as the
error message if the error response body is empty.

https://nodejs.org/en/blog/release/v5.5.0/
nodejs/node#4501
https://nodejs.org/api/http.html#http_event_checkexpectation
https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.18
https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.20
https://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.2.3
mbland pushed a commit to 18F/pages-server that referenced this pull request Feb 1, 2016
Mike Bland
Fix HTTP 417 error when testing with Node v5.5.0
3f8754f
In Node v5.5.0, the HTTP server became more diligent about sending a HTTP 417
Expectation Failed response if the `Expect` header was not `100-continue`.
Since `RequestHelper.httpOptions` was creating requests with an empty `Expect`
header, and did not define a `checkExpectation` event handler, the server
returned 417 errors for these requests.

Also updated `RequestHelper.sendRequest` to use the status code text as the
error message if the error response body is empty.

https://nodejs.org/en/blog/release/v5.5.0/
nodejs/node#4501
https://nodejs.org/api/http.html#http_event_checkexpectation
https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.18
https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.20
https://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html#sec8.2.3
scovetta pushed a commit to scovetta/node that referenced this pull request Apr 2, 2016
@designfrontier Michael Scovetta
http: improves expect header handling
88f013f
Now returns a 417 error status or allows for an event listener on
the `checkExpectation` event. Before we were ignoring requests that
had misspelled `100-continue` values for expect headers.

This is a quick port of the work done here:
nodejs/node-v0.x-archive#7132 by alFReD-NSH
with surrounding discussion here:
nodejs/node-v0.x-archive#4651

Also updates all the instances of the deprecated
EventEmitter.listenerCount to the current self.listenerCount. Most
of these were in the new code ported over but there was another
legacy instance.

Refs: nodejs#2403
PR-URL: nodejs#4501
Reviewed-By: James M Snell <[email protected]>
scovetta pushed a commit to scovetta/node that referenced this pull request Apr 2, 2016
@evanlucas Michael Scovetta
2016-01-20, Version 5.5.0 (Stable)
de2ebef
Notable changes:

* events: make sure console functions exist (Dave) nodejs#4479
* fs: add autoClose option to fs.createWriteStream (Saquib) nodejs#3679
* http: improves expect header handling (Daniel Sellers) nodejs#4501
* node: allow preload modules with -i (Evan Lucas) nodejs#4696
* v8,src: expose statistics about heap spaces (`v8.getHeapSpaceStatistics()`) (Ben Ripkens) nodejs#4463
* Minor performance improvements:
  - lib: Use arrow functions instead of bind where possible (Minwoo Jung) nodejs#3622
  - module: cache stat() results more aggressively (Ben Noordhuis) nodejs#4575
  - querystring: improve parse() performance (Brian White) nodejs#4675

PR-URL: nodejs#4742
trentm added a commit to TritonDataCenter/manta-muskie that referenced this pull request Apr 14, 2020
@trentm
Fix 'ExpectationFailedError' errors in MPU test files due to incorrec…
95abace
…t "Expect" header usage

Many MPU tests were setting "Expect: application/json", a presumed
accidental misspelling of the "Accept" header. The only valid value
for the "Expect" header is "100-continue". Old muskie was using
node 0.10. Sometime after 0.10 nodejs/node#4501
changed node behaviour to respond with 417 Expectation Failed if given
a bogus "Expect" header.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

http Issues and PRs related to the http subsystem. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@designfrontier @jasnell @mscdex @dougwilson @rvagg @evanlucas
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.