http: Improve HTTP Expect header handling #7132

Closed
wants to merge 1 commit into
from

Projects

None yet

5 participants

@alFReD-NSH

Just following the spec:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.20

Fixes #4651

Note that, Now we have the following pattern 3 times in the _http_server.js:

if (EventEmitter.listenerCount(self, 'someEventName') > 0) {
    self.emit('someEventName');
} else {
     // Do something as default
}

I think maybe we should move it to a function, though didn't have any good idea for the name of the function. Something like this. If you guys give me a good name, I'll refactor it.

I also see this pattern in userland too. Maybe it should be a event emitter prototype method name setDefaultListener that will set the default action when there's no listeners but won't do anything when there are listeners to a particular event.

@Nodejs-Jenkins

Thank you for contributing this pull request! Here are a few pointers to make sure your submission will be considered for inclusion.

The following commiters were not found in the CLA:

  • Farid Neshat

You can fix all these things without opening another issue.

Please see CONTRIBUTING.md for more information

@tjfontaine

I'm generally ok with this, but I want to solicit some feedback from others using this feature to know if this would be too much of a surprise.

On the pattern, you could describe it this way:

if (!self.emit('checkExpectation'...)) {
  res.writeHead(417);
  res.end();
}

I'm not really thrilled with the idea of the prototype method.

@trevnorris trevnorris added the http label Feb 18, 2014
@jasnell
Member
jasnell commented Aug 3, 2015

@alFReD-NSH ... still want this?

@alFReD-NSH

I actually don't need this for myself anymore. But should check with #4651

@jasnell
Member
jasnell commented Aug 13, 2015

Ok, given the change I'm not sure if this would land in here or if it should be retargeted to nodejs/node. @alFReD-NSH , are you willing to take another look at this?

@alFReD-NSH

I don't need this anymore. If you think this should be merged, then merge it if not, if it needs any changes, then close this, because at this moment I don't have time for this.

@jasnell
Member
jasnell commented Aug 13, 2015

For now I'll mark it as a low priority and assign myself to it. If I'm able to get back to it I will, otherwise it'll just have to sit a while longer. Thanks @alFReD-NSH !

@jasnell jasnell added the P-3 label Aug 13, 2015
@jasnell jasnell self-assigned this Aug 13, 2015
@jasnell
Member
jasnell commented Aug 16, 2015

Opened a new issue in nodejs/node to track this. Will close this PR as it's not going to be able to land.

@jasnell jasnell closed this Aug 16, 2015
@designfrontier designfrontier added a commit to designfrontier/node that referenced this pull request Dec 31, 2015
@designfrontier designfrontier http: improves expect header handling
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
820687a
@designfrontier designfrontier added a commit to designfrontier/node that referenced this pull request Dec 31, 2015
@designfrontier designfrontier http: improves expect header handling
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
ce42fcd
@designfrontier designfrontier referenced this pull request in nodejs/node Dec 31, 2015
Closed

http: improves expect header handling #4501

@designfrontier designfrontier added a commit to designfrontier/node that referenced this pull request Dec 31, 2015
@designfrontier designfrontier http: improves expect header handling
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
25f7e6a
@designfrontier designfrontier added a commit to designfrontier/node that referenced this pull request Jan 1, 2016
@designfrontier designfrontier http: improves expect header handling
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
2343cb2
@designfrontier designfrontier added a commit to designfrontier/node that referenced this pull request Jan 1, 2016
@designfrontier designfrontier http: improves expect header handling
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
20db3fe
@designfrontier designfrontier added a commit to designfrontier/node that referenced this pull request Jan 6, 2016
@designfrontier designfrontier http: improves expect header handling
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
99b615d
@designfrontier designfrontier added a commit to designfrontier/node that referenced this pull request Jan 6, 2016
@designfrontier designfrontier http: improves expect header handling
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
e7d2033
@designfrontier designfrontier added a commit to designfrontier/node that referenced this pull request Jan 8, 2016
@designfrontier designfrontier http: improves expect header handling
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
810158c
@jasnell jasnell added a commit to nodejs/node that referenced this pull request Jan 13, 2016
@designfrontier @jasnell designfrontier + jasnell http: improves expect header handling
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 <jasnell@gmail.com>
d755432
@evanlucas evanlucas added a commit to nodejs/node that referenced this pull request Jan 18, 2016
@designfrontier @evanlucas designfrontier + evanlucas http: improves expect header handling
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 <jasnell@gmail.com>
c171294
@scovetta scovetta pushed a commit to scovetta/node that referenced this pull request Apr 2, 2016
@designfrontier designfrontier + Michael Scovetta http: improves expect header handling
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: nodejs#4501
Reviewed-By: James M Snell <jasnell@gmail.com>
88f013f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment