Skip to content

Commit 076c2c2

Browse files
ashtonianaddaleax
authored andcommitted
test: test for http.request() invalid method error
Adds a test for when an invalid http method is passed into http.request() to verify an error is thrown, that the error is the correct type, and the error message is correct. PR-URL: #10080 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent f38cb9b commit 076c2c2

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
require('../common');
3+
const assert = require('assert');
4+
const http = require('http');
5+
6+
assert.throws(
7+
() => { http.request({method: '\0'}); },
8+
(error) => {
9+
return (error instanceof TypeError) &&
10+
/Method must be a valid HTTP token/.test(error);
11+
}
12+
);

0 commit comments

Comments
 (0)