@@ -32,15 +32,15 @@ var STRS = {
32
32
} ,
33
33
queryArgs : {
34
34
url : '/?url=' ,
35
- bot : '&bot =' ,
35
+ bot : '&___bot =' ,
36
36
} ,
37
37
enc : {
38
38
base64 : 'base64' ,
39
39
} ,
40
40
} ;
41
41
42
42
var packageDetails = {
43
- version : '2.2 .0' ,
43
+ version : '2.3 .0' ,
44
44
name : 'SPIDERABLE_MIDDLEWARE' ,
45
45
} ;
46
46
@@ -50,7 +50,7 @@ var RE = {
50
50
trailingSlash : / \/ $ / ,
51
51
beginningSlash : / ^ \/ / ,
52
52
digit : / \d + / ,
53
- staticExt : / \. (?: 3 d s | 3 g 2 | 3 g p | 3 g p p | 7 z | a | a a c | a a f | a d p | a i | a i f | a i f f | a l z | a p e | a p k | a p p c a c h e | a r | a r j | a s f | a s x | a t o m | a u | a v c h d | a v i | b a k | b b a w | b h | b i n | b k | b m p | b t i f | b z 2 | b z i p 2 | c a b | c a f | c c o | c g m | c l a s s | c m x | c p i o | c r 2 | c r t | c r x | c s s | c s v | c u r | d a t | d e b | d e r | d e x | d j v u | d l l | d m g | d n g | d o c | d o c m | d o c x | d o t | d o t m | d r a | d r c | D S _ S t o r e | d s k | d t s | d t s h d | d v b | d w g | d x f | e a r | e c e l p 4 8 0 0 | e c e l p 7 4 7 0 | e c e l p 9 6 0 0 | e g g | e o l | e o t | e p s | e p u b | e x e | f 4 a | f 4 b | f 4 p | f 4 v | f b s | f h | f l a | f l a c | f l i | f l v | f p x | f s t | f v t | g 3 | g e o j s o n | g i f | g r a f f l e | g z | g z i p | h 2 6 1 | h 2 6 3 | h 2 6 4 | h q x | h t c | i c o | i e f | i m g | i p a | i s o | j a d | j a r | j a r d i f f | j n g | j n l p | j p e g | j p g | j p g v | j p m | j s | j x r | k e y | k m l | k m z | k t x | l e s s | l h a | l v p | l z | l z h | l z m a | l z o | m 2 v | m 3 u | m 4 a | m 4 p | m 4 v | m a p | m a n i f e s t | m a r | m a r k d o w n | m d | m d i | m d o w n | m d w n | m h t | m i d | m i d i | m j 2 | m k a | m k d | m k d n | m k d o w n | m k v | m m l | m m r | m n g | m o b i | m o v | m o v i e | m p 2 | m p 3 | m p 4 | m p 4 a | m p e | m p e g | m p g | m p g a | m p v | m s i | m s m | m s p | m x f | m x u | n e f | n p x | n s v | n u m b e r s | o | o e x | o g a | o g g | o g v | o p u s | o t f | p a g e s | p b m | p c x | p d b | p d f | p e a | p e m | p g m | p i c | p l | p m | p n g | p n m | p o t | p o t m | p o t x | p p a | p p a m | p p m | p p s | p p s m | p p s x | p p t | p p t m | p p t x | p r c | p s | p s d | p y a | p y c | p y o | p y v | q t | r a | r a r | r a s | r a w | r d f | r g b | r i p | r l c | r m | r m f | r m v b | r o n | r o q | r p m | r s s | r t f | r u n | r z | s 3 m | s 7 z | s a f a r i e x t z | s c p t | s e a | s g i | s h a r | s i l | s i t | s l k | s m v | s o | s u b | s v g | s v g z | s v i | s w f | t a r | t b z | t b z 2 | t c l | t g a | t g z | t h m x | t i f | t i f f | t k | t l z | t o p o j s o n | t o r r e n t | t t c | t t f | t x t | t x z | u d f | u v h | u v i | u v m | u v p | u v s | u v u | v c a r d | v c f | v i v | v o b | v t t | w a r | w a v | w a x | w b m p | w d p | w e b a | w e b a p p | w e b m | w e b m a n i f e s t | w e b p | w h l | w i m | w m | w m a | w m l | w m l c | w m v | w m x | w o f f | w o f f 2 | w v x | x b m | x i f | x l a | x l a m | x l o c | x l s | x l s b | x l s m | x l s x | x l t | x l t m | x l t x | x m | x m i n d | x m l | x p i | x p m | x s l | x w d | x z | y u v | z | z i p | z i p x ) (?: \? [ a - z A - Z 0 - 9 \- \. \_ \~ \: \/ \# \[ \] \@ \! \$ \& \' \( \) \* \+ \, \; \= ] * ) ? $ / i
53
+ staticExt : / \. (?: 3 d s | 3 g 2 | 3 g p | 3 g p p | 7 z | a | a a c | a a f | a d p | a i | a i f | a i f f | a l z | a p e | a p k | a p p c a c h e | a r | a r j | a s f | a s x | a t o m | a u | a v c h d | a v i | b a k | b b a w | b h | b i n | b k | b m p | b t i f | b z 2 | b z i p 2 | c a b | c a f | c c o | c g m | c l a s s | c m x | c p i o | c r 2 | c r t | c r x | c s s | c s v | c u r | d a t | d e b | d e r | d e x | d j v u | d l l | d m g | d n g | d o c | d o c m | d o c x | d o t | d o t m | d r a | d r c | D S _ S t o r e | d s k | d t s | d t s h d | d v b | d w g | d x f | e a r | e c e l p 4 8 0 0 | e c e l p 7 4 7 0 | e c e l p 9 6 0 0 | e g g | e o l | e o t | e p s | e p u b | e x e | f 4 a | f 4 b | f 4 p | f 4 v | f b s | f h | f l a | f l a c | f l i | f l v | f p x | f s t | f v t | g 3 | g e o j s o n | g i f | g r a f f l e | g z | g z i p | h 2 6 1 | h 2 6 3 | h 2 6 4 | h q x | h t c | i c o | i e f | i m g | i p a | i s o | j a d | j a r | j a r d i f f | j n g | j n l p | j p e g | j p g | j p g v | j p m | j s | j x r | k e y | k m l | k m z | k t x | l e s s | l h a | l v p | l z | l z h | l z m a | l z o | m 2 v | m 3 u | m 4 a | m 4 p | m 4 v | m a p | m a n i f e s t | m a r | m a r k d o w n | m d | m d i | m d o w n | m d w n | m h t | m i d | m i d i | m j 2 | m k a | m k d | m k d n | m k d o w n | m k v | m m l | m m r | m n g | m o b i | m o v | m o v i e | m p 2 | m p 3 | m p 4 | m p 4 a | m p e | m p e g | m p g | m p g a | m p v | m s i | m s m | m s p | m x f | m x u | n e f | n p x | n s v | n u m b e r s | o | o e x | o g a | o g g | o g v | o p u s | o t f | p a g e s | p b m | p c x | p d b | p d f | p e a | p e m | p g m | p i c | p l | p m | p n g | p n m | p o t | p o t m | p o t x | p p a | p p a m | p p m | p p s | p p s m | p p s x | p p t | p p t m | p p t x | p r c | p s | p s d | p y a | p y c | p y o | p y v | q t | r a | r a r | r a s | r a w | r d f | r g b | r i p | r l c | r m | r m f | r m v b | r o n | r o q | r p m | r s s | r t f | r u n | r z | s 3 m | s 7 z | s a f a r i e x t z | s c p t | s e a | s g i | s h a r | s i l | s i t | s l k | s m v | s o | s u b | s v g | s v g z | s v i | s w f | t a r | t b z | t b z 2 | t c l | t g a | t g z | t h m x | t i f | t i f f | t k | t l z | t o p o j s o n | t o r r e n t | t t c | t t f | t x t | t x z | u d f | u v h | u v i | u v m | u v p | u v s | u v u | v c a r d | v c f | v i v | v o b | v t t | w a r | w a v | w a x | w b m p | w d p | w e b a | w e b a p p | w e b m | w e b m a n i f e s t | w e b p | w h l | w i m | w m | w m a | w m l | w m l c | w m v | w m x | w o f f | w o f f 2 | w v x | x b m | x i f | x l a | x l a m | x l o c | x l s | x l s b | x l s m | x l s x | x l t | x l t m | x l t x | x m | x m i n d | x m l | x p i | x p m | x s l | x w d | x z | y u v | z | z i p | z i p x ) $ / i
54
54
} ;
55
55
56
56
var isObject = function ( obj ) {
@@ -66,8 +66,6 @@ var _info = function info(...args) {
66
66
console . info . call ( console , '[INFO] [Spiderable-Middleware]' , ...args ) ;
67
67
} ;
68
68
69
- var _debug = function ( ) { } ;
70
-
71
69
/** Class representing a Spiderable */
72
70
module . exports = ( function ( ) {
73
71
/**
@@ -133,11 +131,11 @@ module.exports = (function () {
133
131
this . only = false ;
134
132
}
135
133
136
- if ( this . debug ) {
137
- _debug = function debug ( ... args ) {
134
+ this . _debug = function debug ( ... args ) {
135
+ if ( this . debug ) {
138
136
_info ( '[DEBUG]' , ...args ) ;
139
- } ;
140
- }
137
+ }
138
+ } ;
141
139
142
140
if ( ! this . handler ) {
143
141
this . handler = this . middleware . bind ( this ) ;
@@ -186,7 +184,7 @@ module.exports = (function () {
186
184
this . ignoreRE = false ;
187
185
}
188
186
189
- this . debug && _debug ( 'Spiderable class initiated' , this ) ;
187
+ this . _debug ( 'Spiderable class initiated' , this ) ;
190
188
}
191
189
192
190
/**
@@ -195,7 +193,7 @@ module.exports = (function () {
195
193
* @name botsUA
196
194
* @type {string[] }
197
195
*/
198
- Spiderable . prototype . botsUA = [ '\\.net crawler' , '360spider' , '50\\.nu' , '8bo crawler bot' , 'aboundex' , 'accoona' , 'adldxbot' , 'adsbot-google' , 'ahrefsbot' , 'altavista' , 'appengine-google' , 'applebot' , 'archiver' , 'arielisbot' , 'ask jeeves' , 'auskunftbot' , 'baidumobaider' , 'baiduspider' , 'becomebot' , 'bingbot' , 'bingpreview' , 'bitbot' , 'bitlybot' , 'blitzbot' , 'blogbridge' , 'boardreader' , 'botseer' , 'catchbot' , 'catchpoint bot' , 'charlotte' , 'checklinks' , 'cliqzbot' , 'clumboot' , 'coccocbot' , 'converacrawler' , 'crawl-e' , 'crawlconvera' , 'dataparksearch' , 'daum' , 'deusu' , 'developers\\.google\\.com/+/web/snippet' , 'discordbot' , 'dotbot' , 'duckduckbot' , 'elefent' , 'embedly' , 'evernote' , 'exabot' , 'facebookbot' , 'facebookexternalhit' , 'fatbot' , 'fdse robot' , 'feed seeker bot' , 'feedfetcher' , 'femtosearchbot' , 'findlinks' , 'flamingo_searchengine' , 'flipboard' , 'followsite bot' , 'furlbot' , 'fyberspider' , 'gaisbot' , 'galaxybot' , 'geniebot' , 'genieo' , 'gigablast' , 'gigabot' , 'girafabot' , 'gomezagent' , 'gonzo1' , 'google sketchup' , 'google-structured-data-testing-tool' , 'googlebot' , 'haosouspider' , 'heritrix' , 'holmes' , 'hoowwwer' , 'htdig' , 'ia_archiver' , 'idbot' , 'infuzapp' , 'innovazion crawler' , 'internetarchive' , 'iqdb' , 'iskanie' , 'istellabot' , 'izsearch\\.com' , 'kaloogabot' , 'kaz\\.kz_bot' , 'kd bot' , 'konqueror' , 'kraken' , 'kurzor' , 'larbin' , 'leia' , 'lesnikbot' , 'linguee bot' , 'linkaider' , 'linkapediabot' , 'linkedinbot' , 'lite bot' , 'llaut' , 'lookseek' , 'lycos' , 'mail\\.ru_bot' , 'masidani_bot' , 'masscan' , 'mediapartners-google' , 'metajobbot' , 'mj12bot' , 'mnogosearch' , 'mogimogi' , 'mojeekbot' , 'motominerbot' , 'mozdex' , 'msiecrawler' , 'msnbot' , 'msrbot' , 'netpursual' , 'netresearch' , 'netvibes' , 'newsgator' , 'ng-search' , 'nicebot' , 'nutchcvs' , 'nuzzel' , 'nymesis' , 'objectssearch' , 'odklbot' , 'omgili' , 'oovoo' , 'oozbot' , 'openfosbot' , 'orangebot' , 'orbiter' , 'org_bot' , 'outbrain' , 'pagepeeker' , 'pagesinventory' , 'parsijoobot' , 'paxleframework' , 'peeplo screenshot bot' , 'pinterest' , 'plantynet_webrobot' , 'plukkie' , 'pompos' , 'psbot' , 'quora link preview' , 'qwantify' , 'read%20later' , 'reaper' , 'redcarpet' , 'redditbot' , 'retreiver' , 'riddler' , 'rival iq' , 'rogerbot' , 'saucenao' , 'scooter' , 'scrapy' , 'scrubby' , 'searchie' , 'searchsight' , 'seekbot' , 'semanticdiscovery' , 'seznambot' , 'showyoubot' , 'simplepie' , 'simpy' , 'sitelockspider' , 'skypeuripreview' , 'slack-imgproxy' , 'slackbot' , 'slurp' , 'snappy' , 'sogou' , 'solofield' , 'speedy spider' , 'speedyspider' , 'sputnikbot' , 'stackrambler' , 'teeraidbot' , 'teoma' , 'theusefulbot' , 'thumbshots\\.ru' , 'thumbshotsbot' , 'tineye' , 'toweya\\.com' , 'toweyabot' , 'tumblr' , 'tweetedtimes' , 'tweetmemebot' , 'twitterbot' , 'url2png' , 'vagabondo' , 'vebidoobot' , 'viber' , 'visionutils' , 'vkshare' , 'voilabot' , 'vortex' , 'votay bot' , 'voyager' , 'w3c_validator' , 'wasalive\\.bot' , 'web-sniffer' , 'websquash\\.com' , 'webthumb' , 'whatsapp' , 'whatweb' , 'wire' , 'wotbox' , 'yacybot' , 'yahoo' , 'yandex' , 'yeti' , 'yisouspider' , 'yodaobot' , 'yooglifetchagent' , 'yoozbot' , 'yottaamonitor' , 'yowedo' , 'zao-crawler' , 'zebot_www\\.ze\\.bz' , 'zooshot' , 'zyborg' ] ;
196
+ Spiderable . prototype . botsUA = [ '\\.net crawler' , '360spider' , '50\\.nu' , '8bo crawler bot' , 'aboundex' , 'accoona' , 'adldxbot' , 'adsbot-google' , 'ahrefsbot' , 'altavista' , 'appengine-google' , 'applebot' , 'archiver' , 'arielisbot' , 'ask jeeves' , 'auskunftbot' , 'baidumobaider' , 'baiduspider' , 'becomebot' , 'bingbot' , 'bingpreview' , 'bitbot' , 'bitlybot' , 'blitzbot' , 'blogbridge' , 'boardreader' , 'botseer' , 'catchbot' , 'catchpoint bot' , 'charlotte' , 'checklinks' , 'cliqzbot' , 'clumboot' , 'coccocbot' , 'converacrawler' , 'crawl-e' , 'crawlconvera' , 'dataparksearch' , 'daum' , 'deusu' , 'developers\\.google\\.com/+/web/snippet' , 'discordbot' , 'dotbot' , 'duckduckbot' , 'elefent' , 'embedly' , 'evernote' , 'exabot' , 'facebookbot' , 'facebookexternalhit' , 'fatbot' , 'fdse robot' , 'feed seeker bot' , 'feedfetcher' , 'femtosearchbot' , 'findlinks' , 'flamingo_searchengine' , 'flipboard' , 'followsite bot' , 'furlbot' , 'fyberspider' , 'gaisbot' , 'galaxybot' , 'geniebot' , 'genieo' , 'gigablast' , 'gigabot' , 'girafabot' , 'gomezagent' , 'gonzo1' , 'google sketchup' , 'google-structured-data-testing-tool' , 'googlebot' , 'haosouspider' , 'heritrix' , 'holmes' , 'hoowwwer' , 'htdig' , 'ia_archiver' , 'idbot' , 'infuzapp' , 'innovazion crawler' , 'internetarchive' , 'iqdb' , 'iskanie' , 'istellabot' , 'izsearch\\.com' , 'kaloogabot' , 'kaz\\.kz_bot' , 'kd bot' , 'konqueror' , 'kraken' , 'kurzor' , 'larbin' , 'leia' , 'lesnikbot' , 'linguee bot' , 'linkaider' , 'linkapediabot' , 'linkedinbot' , 'lite bot' , 'llaut' , 'lookseek' , 'lycos' , 'mail\\.ru_bot' , 'masidani_bot' , 'masscan' , 'mediapartners-google' , 'metajobbot' , 'mj12bot' , 'mnogosearch' , 'mogimogi' , 'mojeekbot' , 'motominerbot' , 'mozdex' , 'msiecrawler' , 'msnbot' , 'msrbot' , 'netpursual' , 'netresearch' , 'netvibes' , 'newsgator' , 'ng-search' , 'nicebot' , 'nutchcvs' , 'nuzzel' , 'nymesis' , 'objectssearch' , 'odklbot' , 'omgili' , 'oovoo' , 'oozbot' , 'openfosbot' , 'orangebot' , 'orbiter' , 'org_bot' , 'outbrain' , 'pagepeeker' , 'pagesinventory' , 'parsijoobot' , 'paxleframework' , 'peeplo screenshot bot' , 'pinterest' , 'plantynet_webrobot' , 'plukkie' , 'pompos' , 'psbot' , 'quora link preview' , 'qwantify' , 'read%20later' , 'reaper' , 'redcarpet' , 'redditbot' , 'retreiver' , 'riddler' , 'rival iq' , 'rogerbot' , 'saucenao' , 'scooter' , 'scrapy' , 'scrubby' , 'searchie' , 'searchsight' , 'seekbot' , 'semanticdiscovery' , 'seznambot' , 'showyoubot' , 'simplepie' , 'simpy' , 'sitelockspider' , 'skypeuripreview' , 'slack-imgproxy' , 'slackbot' , 'slurp' , 'snappy' , 'sogou' , 'solofield' , 'speedy spider' , 'speedyspider' , 'sputnikbot' , 'stackrambler' , 'teeraidbot' , 'teoma' , 'theusefulbot' , 'thumbshots\\.ru' , 'thumbshotsbot' , 'tineye' , 'toweya\\.com' , 'toweyabot' , 'tumblr' , 'tweetedtimes' , 'tweetmemebot' , 'twitterbot' , 'url2png' , 'vagabondo' , 'vebidoobot' , 'viber' , 'visionutils' , 'vkshare' , 'voilabot' , 'vortex' , 'votay bot' , 'voyager' , 'w3c_validator' , 'wasalive\\.bot' , 'web-sniffer' , 'websquash\\.com' , 'webthumb' , 'whatsapp' , 'whatweb' , 'wire' , 'wotbox' , 'yacybot' , 'yahoo' , 'yandex' , 'yeti' , 'yisouspider' , 'yodaobot' , 'yooglifetchagent' , 'yoozbot' , 'yottaamonitor' , 'yowedo' , 'zao-crawler' , 'zebot_www\\.ze\\.bz' , 'zooshot' , 'zyborg' , 'ai2bot' , 'amazonbot' , 'anthropic\\.com' , 'bard' , 'bytespider' , 'ccbot' , 'chatgpt-user' , 'claude-web' , 'claudebot' , 'cohere-ai' , 'deepseek' , 'diffbot' , 'duckassistbot' , 'gemini' , 'google-extended' , 'gptbot' , 'grok' , 'meta-external' , 'mistralai' , 'oai-searchbot' , 'omgili' , 'openai\\.com' , 'perplexity\\.ai' , 'perplexitybot' , 'xai' , 'youbot' ] ;
199
197
200
198
/**
201
199
* @memberOf Spiderable
@@ -216,15 +214,14 @@ module.exports = (function () {
216
214
Spiderable . prototype . getServiceURL = function ( urlObj , bua ) {
217
215
var botUA = bua ? bua : '' ;
218
216
var reqUrl = this . rootURL ;
219
- reqUrl += STRS . slash + urlObj . pathname . replace ( RE . beginningSlash , STRS . empty ) ;
220
- // reqUrl = reqUrl.replace(/([^:]\/)\/+/g, '$1');
217
+ reqUrl += STRS . slash + urlObj . pathname . replace ( RE . beginningSlash , STRS . empty ) + urlObj . search ;
221
218
reqUrl = ( this . serviceURL + STRS . queryArgs . url + encodeURIComponent ( reqUrl ) ) ;
222
219
223
220
if ( typeof botUA === STRS . string && botUA . length ) {
224
221
reqUrl += STRS . queryArgs . bot + encodeURIComponent ( botUA ) ;
225
222
}
226
223
227
- this . debug && _debug ( '[getServiceURL] URL:' , reqUrl ) ;
224
+ this . _debug ( '[getServiceURL] URL:' , reqUrl ) ;
228
225
return reqUrl ;
229
226
} ;
230
227
@@ -247,17 +244,20 @@ module.exports = (function () {
247
244
} catch ( e ) {
248
245
// BAD URL IS PASSED!
249
246
// IGNORING AND PASSING DOWN TO THE APP
250
- this . debug && _debug ( '[getRequestURL] [bad url]' , path , req . url , e ) ;
247
+ this . _debug ( '[getRequestURL] [bad url]' , path , req . url , e ) ;
251
248
return false ;
252
249
}
253
250
254
251
urlObj . pathname = urlObj . pathname . replace ( RE . beginningSlash , STRS . empty ) ;
255
252
var escapedFragment = urlObj . searchParams . has ( STRS . escapedFragment ) ? urlObj . searchParams . get ( STRS . escapedFragment ) : false ;
256
- if ( escapedFragment && typeof escapedFragment === STRS . string && escapedFragment . length ) {
257
- urlObj . pathname += STRS . slash + ( escapedFragment . replace ( RE . beginningSlash , STRS . empty ) ) ;
253
+ if ( escapedFragment && typeof escapedFragment === STRS . string ) {
254
+ urlObj . searchParams . delete ( STRS . escapedFragment ) ;
255
+ if ( escapedFragment . length ) {
256
+ urlObj . pathname += STRS . slash + ( escapedFragment . replace ( RE . beginningSlash , STRS . empty ) ) ;
257
+ }
258
258
}
259
259
260
- this . debug && _debug ( '[getRequestURL] URL:' , urlObj . toString ( ) ) ;
260
+ this . _debug ( '[getRequestURL] URL:' , urlObj . toString ( ) ) ;
261
261
262
262
if ( ! this . botsRE . test ( req . headers [ STRS . ua ] || STRS . empty ) && escapedFragment === false ) {
263
263
return false ;
@@ -276,7 +276,7 @@ module.exports = (function () {
276
276
*/
277
277
Spiderable . prototype . middleware = function ( req , res , next ) {
278
278
if ( this . NAME !== packageDetails . name ) {
279
- _warn ( 'middleware has lost its context, ensure it\'s binded back, for example: `spiderable.handle.bind(spiderable)`' ) ;
279
+ _warn ( 'middleware has lost its context, ensure it\'s binds back, for example: `spiderable.handle.bind(spiderable)`' ) ;
280
280
return false ;
281
281
}
282
282
@@ -333,7 +333,7 @@ module.exports = (function () {
333
333
}
334
334
335
335
if ( hasIgnored ) {
336
- this . debug && _debug ( '[middleware] [hasIgnored]' , urlObj . pathname ) ;
336
+ this . _debug ( '[middleware] [hasIgnored]' , urlObj . pathname ) ;
337
337
next ( ) ;
338
338
return false ;
339
339
}
@@ -370,7 +370,7 @@ module.exports = (function () {
370
370
try {
371
371
var _headersRE = this . headersRE ;
372
372
var url = new URL ( reqUrl ) ;
373
- this . debug && _debug ( '[middleware] [requesting]' , url . toString ( ) ) ;
373
+ this . _debug ( '[middleware] [requesting]' , url . toString ( ) ) ;
374
374
var serviceReq = https . request ( url , payload , function ( resp ) {
375
375
for ( var _hName in resp . headers ) {
376
376
if ( resp . headers [ _hName ] ) {
@@ -386,27 +386,27 @@ module.exports = (function () {
386
386
}
387
387
388
388
if ( method === STRS . head ) {
389
- self . debug && _debug ( '[middleware] [request] [HEAD] [received and end]' , resp . statusCode ) ;
389
+ self . _debug ( '[middleware] [request] [HEAD] [received and end]' , resp . statusCode ) ;
390
390
res . writeHead ( resp . statusCode ) ;
391
391
res . end ( ) ;
392
392
return ;
393
393
}
394
394
395
395
if ( ! res . headersSent ) {
396
- self . debug && _debug ( '[middleware] [request] [writeHead]' , resp . statusCode ) ;
396
+ self . _debug ( '[middleware] [request] [writeHead]' , resp . statusCode ) ;
397
397
res . writeHead ( resp . statusCode ) ;
398
398
}
399
399
400
400
res . write ( nullBuf ) ;
401
401
resp . on ( 'data' , function ( data ) {
402
- self . debug && _debug ( '[middleware] [response] [data received]' , res . finished , res . writableEnded ) ;
402
+ self . _debug ( '[middleware] [response] [data received]' , res . finished , res . writableEnded ) ;
403
403
if ( ! res . finished && ! res . writableEnded ) {
404
404
res . write ( data ) ;
405
405
}
406
406
} ) ;
407
407
408
408
resp . on ( 'end' , function ( data ) {
409
- self . debug && _debug ( '[middleware] [response] [end successfully]' , res . finished , res . writableEnded ) ;
409
+ self . _debug ( '[middleware] [response] [end successfully]' , res . finished , res . writableEnded ) ;
410
410
if ( ! res . finished && ! res . writableEnded ) {
411
411
res . end ( data ) ;
412
412
}
@@ -415,7 +415,7 @@ module.exports = (function () {
415
415
416
416
var isEnded = false ;
417
417
var onEnd = function ( error ) {
418
- self . debug && _debug ( '[middleware] [onEnd]' , error ) ;
418
+ self . _debug ( '[middleware] [onEnd]' , error ) ;
419
419
if ( isEnded ) {
420
420
return ;
421
421
}
@@ -463,7 +463,7 @@ module.exports = (function () {
463
463
} ) ;
464
464
465
465
req . on ( 'aborted' , function ( ) {
466
- self . debug && _debug ( '[middleware] [req.aborted]' , arguments ) ;
466
+ self . _debug ( '[middleware] [req.aborted]' , arguments ) ;
467
467
// No need to log this event as nothing bad happened
468
468
// this simply means host which sent this request
469
469
// has aborted the connection or got disconnected
0 commit comments