11cb0ef41Sopenharmony_ci'use strict'; 21cb0ef41Sopenharmony_ci 31cb0ef41Sopenharmony_ciconst { 41cb0ef41Sopenharmony_ci Symbol, 51cb0ef41Sopenharmony_ci Date, 61cb0ef41Sopenharmony_ci DatePrototypeGetMilliseconds, 71cb0ef41Sopenharmony_ci DatePrototypeToUTCString, 81cb0ef41Sopenharmony_ci} = primordials; 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ciconst { setUnrefTimeout } = require('internal/timers'); 111cb0ef41Sopenharmony_ciconst { trace, isTraceCategoryEnabled } = internalBinding('trace_events'); 121cb0ef41Sopenharmony_ciconst { 131cb0ef41Sopenharmony_ci CHAR_LOWERCASE_B, 141cb0ef41Sopenharmony_ci CHAR_LOWERCASE_E, 151cb0ef41Sopenharmony_ci} = require('internal/constants'); 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_cilet utcCache; 181cb0ef41Sopenharmony_ci 191cb0ef41Sopenharmony_cifunction utcDate() { 201cb0ef41Sopenharmony_ci if (!utcCache) cache(); 211cb0ef41Sopenharmony_ci return utcCache; 221cb0ef41Sopenharmony_ci} 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_cifunction cache() { 251cb0ef41Sopenharmony_ci const d = new Date(); 261cb0ef41Sopenharmony_ci utcCache = DatePrototypeToUTCString(d); 271cb0ef41Sopenharmony_ci setUnrefTimeout(resetCache, 1000 - DatePrototypeGetMilliseconds(d)); 281cb0ef41Sopenharmony_ci} 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_cifunction resetCache() { 311cb0ef41Sopenharmony_ci utcCache = undefined; 321cb0ef41Sopenharmony_ci} 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_cilet traceEventId = 0; 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_cifunction getNextTraceEventId() { 371cb0ef41Sopenharmony_ci return ++traceEventId; 381cb0ef41Sopenharmony_ci} 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_cifunction isTraceHTTPEnabled() { 411cb0ef41Sopenharmony_ci return isTraceCategoryEnabled('node.http'); 421cb0ef41Sopenharmony_ci} 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ciconst traceEventCategory = 'node,node.http'; 451cb0ef41Sopenharmony_ci 461cb0ef41Sopenharmony_cifunction traceBegin(...args) { 471cb0ef41Sopenharmony_ci trace(CHAR_LOWERCASE_B, traceEventCategory, ...args); 481cb0ef41Sopenharmony_ci} 491cb0ef41Sopenharmony_ci 501cb0ef41Sopenharmony_cifunction traceEnd(...args) { 511cb0ef41Sopenharmony_ci trace(CHAR_LOWERCASE_E, traceEventCategory, ...args); 521cb0ef41Sopenharmony_ci} 531cb0ef41Sopenharmony_ci 541cb0ef41Sopenharmony_cimodule.exports = { 551cb0ef41Sopenharmony_ci kOutHeaders: Symbol('kOutHeaders'), 561cb0ef41Sopenharmony_ci kNeedDrain: Symbol('kNeedDrain'), 571cb0ef41Sopenharmony_ci utcDate, 581cb0ef41Sopenharmony_ci traceBegin, 591cb0ef41Sopenharmony_ci traceEnd, 601cb0ef41Sopenharmony_ci getNextTraceEventId, 611cb0ef41Sopenharmony_ci isTraceHTTPEnabled, 621cb0ef41Sopenharmony_ci}; 63