You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhancement: Move curl debug logging to --debug-https (#3120)
* As all the curl engine reuse is now stable, move debug logging of curl engine stack to --debug-https
* Extract the DataCentre information from the http response header to use in application output
* Align 'Remaining Free Space' to accommodate Data Centre output
// Cleanup this instance internal variables that may have been set
457
476
voidcleanup(bool flushCookies = false) {
458
477
// Reset any values to defaults, freeing any set objects
459
-
if (debugLogging) {addLogEntry("CurlEngine cleanup() called on instance id: "~ to!string(internalThreadId), ["debug"]);}
478
+
if ((debugLogging) && (debugHTTPSResponse)) {addLogEntry("CurlEngine cleanup() called on instance id: "~ to!string(internalThreadId), ["debug"]);}
460
479
461
480
// Is the instance is stopped?
462
481
if (!http.isStopped) {
@@ -493,23 +512,23 @@ class CurlEngine {
493
512
// Shut down the curl instance & close any open sockets
494
513
voidshutdownCurlHTTPInstance() {
495
514
// Log that we are attempting to shutdown this curl instance
496
-
if (debugLogging) {addLogEntry("CurlEngine shutdownCurlHTTPInstance() called on instance id: "~ to!string(internalThreadId), ["debug"]);}
515
+
if ((debugLogging) && (debugHTTPSResponse)) {addLogEntry("CurlEngine shutdownCurlHTTPInstance() called on instance id: "~ to!string(internalThreadId), ["debug"]);}
497
516
498
517
// Is this curl instance is stopped?
499
518
if (!http.isStopped) {
500
-
if (debugLogging) {
519
+
if ((debugLogging) && (debugHTTPSResponse)) {
501
520
addLogEntry("HTTP instance still active: "~ to!string(internalThreadId), ["debug"]);
502
521
addLogEntry("HTTP instance isStopped state before http.shutdown(): "~ to!string(http.isStopped), ["debug"]);
503
522
}
504
523
http.shutdown();
505
-
if (debugLogging) {addLogEntry("HTTP instance isStopped state post http.shutdown(): "~ to!string(http.isStopped), ["debug"]);}
524
+
if ((debugLogging) && (debugHTTPSResponse)) {addLogEntry("HTTP instance isStopped state post http.shutdown(): "~ to!string(http.isStopped), ["debug"]);}
506
525
object.destroy(http); // Destroy, however we cant set to null
507
-
if (debugLogging) {addLogEntry("HTTP instance shutdown and destroyed: "~ to!string(internalThreadId), ["debug"]);}
526
+
if ((debugLogging) && (debugHTTPSResponse)) {addLogEntry("HTTP instance shutdown and destroyed: "~ to!string(internalThreadId), ["debug"]);}
508
527
509
528
} else {
510
529
// Already stopped .. destroy it
511
530
object.destroy(http); // Destroy, however we cant set to null
512
-
if (debugLogging) {addLogEntry("Stopped HTTP instance shutdown and destroyed: "~ to!string(internalThreadId), ["debug"]);}
531
+
if ((debugLogging) && (debugHTTPSResponse)) {addLogEntry("Stopped HTTP instance shutdown and destroyed: "~ to!string(internalThreadId), ["debug"]);}
513
532
}
514
533
// Perform Garbage Collection
515
534
GC.collect();
@@ -522,14 +541,14 @@ class CurlEngine {
522
541
523
542
// Get a curl instance for the OneDrive API to use
524
543
CurlEngine getCurlInstance() {
525
-
if (debugLogging) {addLogEntry("CurlEngine getCurlInstance() called", ["debug"]);}
544
+
if ((debugLogging) && (debugHTTPSResponse)) {addLogEntry("CurlEngine getCurlInstance() called", ["debug"]);}
526
545
527
546
synchronized (CurlEngine.classinfo) {
528
547
// What is the current pool size
529
-
if (debugLogging) {addLogEntry("CurlEngine curlEnginePool current size: "~ to!string(curlEnginePool.length), ["debug"]);}
548
+
if ((debugLogging) && (debugHTTPSResponse)) {addLogEntry("CurlEngine curlEnginePool current size: "~ to!string(curlEnginePool.length), ["debug"]);}
530
549
531
550
if (curlEnginePool.empty) {
532
-
if (debugLogging) {addLogEntry("CurlEngine curlEnginePool is empty - constructing a new CurlEngine instance", ["debug"]);}
551
+
if ((debugLogging) && (debugHTTPSResponse)) {addLogEntry("CurlEngine curlEnginePool is empty - constructing a new CurlEngine instance", ["debug"]);}
533
552
returnnew CurlEngine; // Constructs a new CurlEngine with a fresh HTTP instance
// return a new curl engine as a stopped one cannot be used
541
-
if (debugLogging) {addLogEntry("CurlEngine was in a stopped state (not usable) - constructing a new CurlEngine instance", ["debug"]);}
560
+
if ((debugLogging) && (debugHTTPSResponse)) {addLogEntry("CurlEngine was in a stopped state (not usable) - constructing a new CurlEngine instance", ["debug"]);}
542
561
returnnew CurlEngine; // Constructs a new CurlEngine with a fresh HTTP instance
543
562
} else {
544
563
// When was this engine last used?
545
564
auto elapsedTime = Clock.currTime(UTC()) - curlEngine.releaseTimestamp;
546
-
if (debugLogging) {
565
+
if ((debugLogging) && (debugHTTPSResponse)) {
547
566
string engineIdleMessage = format("CurlEngine %s time since last use: %s", to!string(curlEngine.internalThreadId), to!string(elapsedTime));
if (elapsedTime > dur!"seconds"(curlEngine.maxIdleTime)) {
557
576
// Too long idle engine, clean it up and create a new one
558
-
if (debugLogging) {
577
+
if ((debugLogging) && (debugHTTPSResponse)) {
559
578
string curlTooOldMessage = format("CurlEngine idle for > %d seconds .... destroying and returning a new curl engine instance", curlEngine.maxIdleTime);
560
579
addLogEntry(curlTooOldMessage, ["debug"]);
561
580
}
562
581
563
582
curlEngine.cleanup(true); // Cleanup instance by resetting values and flushing cookie cache
564
583
curlEngine.shutdownCurlHTTPInstance(); // Assume proper cleanup of any resources used by HTTP
565
-
if (debugLogging) {addLogEntry("Returning NEW curlEngine instance", ["debug"]);}
584
+
if ((debugLogging) && (debugHTTPSResponse)) {addLogEntry("Returning NEW curlEngine instance", ["debug"]);}
566
585
returnnew CurlEngine; // Constructs a new CurlEngine with a fresh HTTP instance
567
586
} else {
568
587
// return an existing curl engine
569
-
if (debugLogging) {
588
+
if ((debugLogging) && (debugHTTPSResponse)) {
570
589
addLogEntry("CurlEngine was in a valid state - returning existing CurlEngine instance", ["debug"]);
0 commit comments