20
20
// USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
22
22
'use strict' ;
23
- const common = require ( '../common' ) ;
23
+ const { mustCall , mustNotCall } = require ( '../common' ) ;
24
24
const assert = require ( 'assert' ) ;
25
25
26
- const binding = process . binding ( 'http_parser' ) ;
27
- const methods = binding . methods ;
28
- const HTTPParser = binding . HTTPParser ;
29
-
30
- const REQUEST = HTTPParser . REQUEST ;
31
- const RESPONSE = HTTPParser . RESPONSE ;
26
+ const { methods, HTTPParser } = process . binding ( 'http_parser' ) ;
27
+ const { REQUEST , RESPONSE } = HTTPParser ;
32
28
33
29
const kOnHeaders = HTTPParser . kOnHeaders | 0 ;
34
30
const kOnHeadersComplete = HTTPParser . kOnHeadersComplete | 0 ;
@@ -55,7 +51,7 @@ function newParser(type) {
55
51
parser [ kOnHeadersComplete ] = function ( ) {
56
52
} ;
57
53
58
- parser [ kOnBody ] = common . mustNotCall ( 'kOnBody should not be called' ) ;
54
+ parser [ kOnBody ] = mustNotCall ( 'kOnBody should not be called' ) ;
59
55
60
56
parser [ kOnMessageComplete ] = function ( ) {
61
57
} ;
@@ -64,21 +60,6 @@ function newParser(type) {
64
60
}
65
61
66
62
67
- function mustCall ( f , times ) {
68
- let actual = 0 ;
69
-
70
- process . setMaxListeners ( 256 ) ;
71
- process . on ( 'exit' , function ( ) {
72
- assert . strictEqual ( actual , times || 1 ) ;
73
- } ) ;
74
-
75
- return function ( ) {
76
- actual ++ ;
77
- return f . apply ( this , Array . prototype . slice . call ( arguments ) ) ;
78
- } ;
79
- }
80
-
81
-
82
63
function expectBody ( expected ) {
83
64
return mustCall ( function ( buf , start , len ) {
84
65
const body = String ( buf . slice ( start , start + len ) ) ;
0 commit comments