2020// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121
2222'use strict' ;
23- const common = require ( '../common' ) ;
23+ const { mustCall , mustNotCall } = require ( '../common' ) ;
2424const assert = require ( 'assert' ) ;
2525
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 ;
3228
3329const kOnHeaders = HTTPParser . kOnHeaders | 0 ;
3430const kOnHeadersComplete = HTTPParser . kOnHeadersComplete | 0 ;
@@ -55,7 +51,7 @@ function newParser(type) {
5551 parser [ kOnHeadersComplete ] = function ( ) {
5652 } ;
5753
58- parser [ kOnBody ] = common . mustNotCall ( 'kOnBody should not be called' ) ;
54+ parser [ kOnBody ] = mustNotCall ( 'kOnBody should not be called' ) ;
5955
6056 parser [ kOnMessageComplete ] = function ( ) {
6157 } ;
@@ -64,21 +60,6 @@ function newParser(type) {
6460}
6561
6662
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-
8263function expectBody ( expected ) {
8364 return mustCall ( function ( buf , start , len ) {
8465 const body = String ( buf . slice ( start , start + len ) ) ;
0 commit comments