@@ -72,7 +72,7 @@ export abstract class ExchangeServiceBase {
72
72
private clientRequestId : string = null ;
73
73
private returnClientRequestId : boolean = false ;
74
74
// private cookieContainer: CookieContainer = new CookieContainer();
75
- protected timeZone : TimeZoneInfo = null ;
75
+ protected timeZone : TimeZoneInfo = TimeZoneInfo . Local ;
76
76
private timeZoneDefinition : TimeZoneDefinition = null ;
77
77
private serverInfo : ExchangeServerInfo = null ;
78
78
// private webProxy: IWebProxy = null;
@@ -371,24 +371,24 @@ export abstract class ExchangeServiceBase {
371
371
//#region Constructor
372
372
373
373
/**
374
- * @internal Initializes a new instance of the **ExchangeServiceBase** class.
374
+ * Initializes a new instance of the **ExchangeServiceBase** class.
375
375
*
376
376
*/
377
377
constructor ( ) ;
378
378
/**
379
- * @internal Initializes a new instance of the **ExchangeServiceBase** class.
379
+ * Initializes a new instance of the **ExchangeServiceBase** class.
380
380
*
381
381
* @param {TimeZoneInfo } timeZone The time zone to which the service is scoped.
382
382
*/
383
383
constructor ( timeZone : TimeZoneInfo ) ;
384
384
/**
385
- * @internal Initializes a new instance of the **ExchangeServiceBase** class.
385
+ * Initializes a new instance of the **ExchangeServiceBase** class.
386
386
*
387
387
* @param {ExchangeVersion } requestedServerVersion The requested server version.
388
388
*/
389
389
constructor ( requestedServerVersion : ExchangeVersion ) ;
390
390
/**
391
- * @internal Initializes a new instance of the **ExchangeServiceBase** class.
391
+ * Initializes a new instance of the **ExchangeServiceBase** class.
392
392
*
393
393
* @param {ExchangeVersion } requestedServerVersion The requested server version.
394
394
* @param {TimeZoneInfo } timeZone The time zone to which the service is scoped.
@@ -445,10 +445,13 @@ export abstract class ExchangeServiceBase {
445
445
}
446
446
}
447
447
448
-
449
-
450
448
this . requestedServerVersion = requestedServerVersion ;
451
449
450
+ if ( hasValue ( timeZone ) ) {
451
+ this . timeZone = timeZone ;
452
+ //this.useDefaultCredentials = true; //ref: no default credential in node.js
453
+ }
454
+
452
455
if ( hasValue ( service ) ) {
453
456
// this.useDefaultCredentials = service.useDefaultCredentials;
454
457
this . credentials = service . credentials ;
@@ -467,11 +470,6 @@ export abstract class ExchangeServiceBase {
467
470
// this.ewsHttpWebRequestFactory = service.ewsHttpWebRequestFactory;
468
471
this . xhrApi = service . xhrApi ;
469
472
}
470
-
471
- if ( timeZone !== null && typeof timeZone !== 'undefined' ) {
472
- this . timeZone = timeZone ;
473
- //this.useDefaultCredentials = true; //ref: no default credential in node.js
474
- }
475
473
}
476
474
//#endregion
477
475
@@ -713,18 +711,18 @@ export abstract class ExchangeServiceBase {
713
711
}
714
712
715
713
// REF: no default credential in NodeJs
716
- //request.UseDefaultCredentials = this.UseDefaultCredentials;
714
+ // request.UseDefaultCredentials = this.UseDefaultCredentials;
717
715
// if (!this.UseDefaultCredentials) {
718
- // var serviceCredentials = this.Credentials;
719
- // if (serviceCredentials === null) {
720
- // throw new ServiceLocalException(Strings.CredentialsRequired);
721
- // }
716
+ var serviceCredentials = this . Credentials ;
717
+ if ( serviceCredentials === null ) {
718
+ throw new ServiceLocalException ( Strings . CredentialsRequired ) ;
719
+ }
722
720
723
- // // Make sure that credentials have been authenticated if required
724
- // // serviceCredentials.PreAuthenticate(); //todo: fix preauthenticate if possible
721
+ // Make sure that credentials have been authenticated if required
722
+ //serviceCredentials.PreAuthenticate(); //todo: fix preauthenticate if possible
725
723
726
- // // Apply credentials to the request
727
- // serviceCredentials.PrepareWebRequest(request);
724
+ // Apply credentials to the request
725
+ serviceCredentials . PrepareWebRequest ( request ) ;
728
726
// }
729
727
// else
730
728
// debugger;
@@ -749,28 +747,27 @@ export abstract class ExchangeServiceBase {
749
747
* @param {XMLHttpRequest } response The response.
750
748
*/
751
749
ProcessHttpResponseHeaders ( traceType : TraceFlags , response : XMLHttpRequest ) : void {
752
- return ;
753
- //todo: implement tracing
750
+ //TODO: implement tracing properly
754
751
this . TraceHttpResponseHeaders ( traceType , response ) ;
755
752
756
- this . SaveHttpResponseHeaders ( response . getAllResponseHeaders ( ) ) ;
753
+ this . SaveHttpResponseHeaders ( response ) ;
757
754
}
758
755
759
756
/**
760
757
* Save the HTTP response headers.
761
758
*
762
- * @param {Object } headers The response headers
759
+ * @param {Object } response The response headers
763
760
*/
764
- private SaveHttpResponseHeaders ( headers : any /* System.Net.WebHeaderCollection*/ ) : any {
761
+ private SaveHttpResponseHeaders ( response : any /* System.Net.WebHeaderCollection*/ ) : any {
765
762
//debug:
766
763
this . httpResponseHeaders . clear ( ) ;
767
764
768
- for ( var key in headers . headers ) {
769
- this . httpResponseHeaders . Add ( key , headers . headers [ key ] ) ;
765
+ for ( var key in response . headers || { } ) {
766
+ this . httpResponseHeaders . Add ( key , response . headers [ key ] ) ;
770
767
}
771
768
772
769
if ( this . OnResponseHeadersCaptured != null ) {
773
- this . OnResponseHeadersCaptured ( headers ) ;
770
+ this . OnResponseHeadersCaptured ( this . httpResponseHeaders ) ;
774
771
}
775
772
}
776
773
0 commit comments