16
16
*/
17
17
18
18
// uncomment to enable debugging
19
- // #define ENABLE_DEBUGGING
19
+ #define ENABLE_DEBUGGING
20
20
21
21
using IBM . Watson . DeveloperCloud . Utilities ;
22
22
using IBM . Watson . DeveloperCloud . Logging ;
@@ -489,6 +489,11 @@ private IEnumerator ProcessRequestQueue()
489
489
}
490
490
else
491
491
{
492
+
493
+ #if ENABLE_DEBUGGING
494
+ Log . Debug ( "RESTConnector" , "Delete Request URL: {0}" , url ) ;
495
+ #endif
496
+
492
497
#if UNITY_EDITOR
493
498
float timeout = Mathf . Max ( Config . Instance . TimeOut , req . Timeout ) ;
494
499
@@ -507,6 +512,7 @@ private IEnumerator ProcessRequestQueue()
507
512
continue ;
508
513
509
514
resp . Success = deleteReq . Success ;
515
+
510
516
#else
511
517
Log . Warning ( "RESTConnector" , "DELETE method is supported in the editor only." ) ;
512
518
resp . Success = false ;
@@ -530,8 +536,13 @@ private class DeleteRequest
530
536
public bool IsComplete { get ; set ; }
531
537
public bool Success { get ; set ; }
532
538
539
+ private Thread m_Thread = null ;
540
+
533
541
public bool Send ( string url , Dictionary < string , string > headers )
534
542
{
543
+ #if ENABLE_DEBUGGING
544
+ Log . Debug ( "RESTConnector" , "DeleteRequest, Send: {0}, m_Thread:{1}" , url , m_Thread ) ;
545
+ #endif
535
546
if ( m_Thread != null && m_Thread . IsAlive )
536
547
return false ;
537
548
@@ -544,24 +555,37 @@ public bool Send(string url, Dictionary<string, string> headers)
544
555
}
545
556
546
557
m_Thread = new Thread ( ProcessRequest ) ;
558
+
547
559
m_Thread . Start ( ) ;
548
560
return true ;
549
561
}
550
-
551
- private Thread m_Thread = null ;
552
-
562
+
553
563
private void ProcessRequest ( )
554
564
{
555
565
// This fixes the exception thrown by self-signed certificates.
556
566
ServicePointManager . ServerCertificateValidationCallback = new RemoteCertificateValidationCallback ( delegate { return true ; } ) ;
557
567
568
+ #if ENABLE_DEBUGGING
569
+ Log . Debug ( "RESTConnector" , "DeleteRequest, ProcessRequest {0}" , URL ) ;
570
+ #endif
571
+
558
572
WebRequest deleteReq = WebRequest . Create ( URL ) ;
573
+
559
574
foreach ( var kp in Headers )
560
575
deleteReq . Headers . Add ( kp . Key , kp . Value ) ;
561
576
deleteReq . Method = "DELETE" ;
562
577
578
+ #if ENABLE_DEBUGGING
579
+ Log . Debug ( "RESTConnector" , "DeleteRequest, sending deletereq {0}" , deleteReq ) ;
580
+ #endif
563
581
HttpWebResponse deleteResp = deleteReq . GetResponse ( ) as HttpWebResponse ;
582
+ #if ENABLE_DEBUGGING
583
+ Log . Debug ( "RESTConnector" , "DELETE Request SENT: {0}" , URL ) ;
584
+ #endif
564
585
Success = deleteResp . StatusCode == HttpStatusCode . OK ;
586
+ #if ENABLE_DEBUGGING
587
+ Log . Debug ( "RESTConnector" , "DELETE Request COMPLETE: {0}" , URL ) ;
588
+ #endif
565
589
IsComplete = true ;
566
590
}
567
591
} ;
0 commit comments