Skip to content
This repository has been archived by the owner on Dec 8, 2017. It is now read-only.

Commit

Permalink
Fix HTTP 417 error when testing with Node v5.5.0
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Mike Bland committed Feb 1, 2016
1 parent 334535d commit 3f8754f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions test/request-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ RequestHelper.prototype.httpOptions = function(port, payload, secret) {
method: 'POST',
headers: {
'content-type': 'application/json',
'Expect': '',
'Expect': '100-continue',
'User-Agent': 'GitHub-Hookshot/9db916b',
'X-GitHub-Delivery': '01234567-0123-0123-1234-0123456789ab',
'X-GitHub-Event': 'push',
Expand Down Expand Up @@ -71,7 +71,8 @@ RequestHelper.prototype.sendRequest = function(options, payload) {
if (res.statusCode >= 200 && res.statusCode <= 300) {
resolve(data);
} else {
reject(new Error(data));
reject(new Error(
data.length !== 0 ? data : http.STATUS_CODES[res.statusCode]));
}
});
});
Expand Down

0 comments on commit 3f8754f

Please sign in to comment.