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

Commit 3f8754f

Browse files
author
Mike Bland
committed
Fix HTTP 417 error when testing with Node v5.5.0
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
1 parent 334535d commit 3f8754f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

test/request-helper.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ RequestHelper.prototype.httpOptions = function(port, payload, secret) {
2424
method: 'POST',
2525
headers: {
2626
'content-type': 'application/json',
27-
'Expect': '',
27+
'Expect': '100-continue',
2828
'User-Agent': 'GitHub-Hookshot/9db916b',
2929
'X-GitHub-Delivery': '01234567-0123-0123-1234-0123456789ab',
3030
'X-GitHub-Event': 'push',
@@ -71,7 +71,8 @@ RequestHelper.prototype.sendRequest = function(options, payload) {
7171
if (res.statusCode >= 200 && res.statusCode <= 300) {
7272
resolve(data);
7373
} else {
74-
reject(new Error(data));
74+
reject(new Error(
75+
data.length !== 0 ? data : http.STATUS_CODES[res.statusCode]));
7576
}
7677
});
7778
});

0 commit comments

Comments
 (0)