@@ -72,7 +72,7 @@ export abstract class ExchangeServiceBase {
7272 private clientRequestId : string = null ;
7373 private returnClientRequestId : boolean = false ;
7474 // private cookieContainer: CookieContainer = new CookieContainer();
75- protected timeZone : TimeZoneInfo = null ;
75+ protected timeZone : TimeZoneInfo = TimeZoneInfo . Local ;
7676 private timeZoneDefinition : TimeZoneDefinition = null ;
7777 private serverInfo : ExchangeServerInfo = null ;
7878 // private webProxy: IWebProxy = null;
@@ -371,24 +371,24 @@ export abstract class ExchangeServiceBase {
371371 //#region Constructor
372372
373373 /**
374- * @internal Initializes a new instance of the **ExchangeServiceBase** class.
374+ * Initializes a new instance of the **ExchangeServiceBase** class.
375375 *
376376 */
377377 constructor ( ) ;
378378 /**
379- * @internal Initializes a new instance of the **ExchangeServiceBase** class.
379+ * Initializes a new instance of the **ExchangeServiceBase** class.
380380 *
381381 * @param {TimeZoneInfo } timeZone The time zone to which the service is scoped.
382382 */
383383 constructor ( timeZone : TimeZoneInfo ) ;
384384 /**
385- * @internal Initializes a new instance of the **ExchangeServiceBase** class.
385+ * Initializes a new instance of the **ExchangeServiceBase** class.
386386 *
387387 * @param {ExchangeVersion } requestedServerVersion The requested server version.
388388 */
389389 constructor ( requestedServerVersion : ExchangeVersion ) ;
390390 /**
391- * @internal Initializes a new instance of the **ExchangeServiceBase** class.
391+ * Initializes a new instance of the **ExchangeServiceBase** class.
392392 *
393393 * @param {ExchangeVersion } requestedServerVersion The requested server version.
394394 * @param {TimeZoneInfo } timeZone The time zone to which the service is scoped.
@@ -445,10 +445,13 @@ export abstract class ExchangeServiceBase {
445445 }
446446 }
447447
448-
449-
450448 this . requestedServerVersion = requestedServerVersion ;
451449
450+ if ( hasValue ( timeZone ) ) {
451+ this . timeZone = timeZone ;
452+ //this.useDefaultCredentials = true; //ref: no default credential in node.js
453+ }
454+
452455 if ( hasValue ( service ) ) {
453456 // this.useDefaultCredentials = service.useDefaultCredentials;
454457 this . credentials = service . credentials ;
@@ -467,11 +470,6 @@ export abstract class ExchangeServiceBase {
467470 // this.ewsHttpWebRequestFactory = service.ewsHttpWebRequestFactory;
468471 this . xhrApi = service . xhrApi ;
469472 }
470-
471- if ( timeZone !== null && typeof timeZone !== 'undefined' ) {
472- this . timeZone = timeZone ;
473- //this.useDefaultCredentials = true; //ref: no default credential in node.js
474- }
475473 }
476474 //#endregion
477475
@@ -713,18 +711,18 @@ export abstract class ExchangeServiceBase {
713711 }
714712
715713 // REF: no default credential in NodeJs
716- //request.UseDefaultCredentials = this.UseDefaultCredentials;
714+ // request.UseDefaultCredentials = this.UseDefaultCredentials;
717715 // 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+ }
722720
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
725723
726- // // Apply credentials to the request
727- // serviceCredentials.PrepareWebRequest(request);
724+ // Apply credentials to the request
725+ serviceCredentials . PrepareWebRequest ( request ) ;
728726 // }
729727 // else
730728 // debugger;
@@ -749,28 +747,27 @@ export abstract class ExchangeServiceBase {
749747 * @param {XMLHttpRequest } response The response.
750748 */
751749 ProcessHttpResponseHeaders ( traceType : TraceFlags , response : XMLHttpRequest ) : void {
752- return ;
753- //todo: implement tracing
750+ //TODO: implement tracing properly
754751 this . TraceHttpResponseHeaders ( traceType , response ) ;
755752
756- this . SaveHttpResponseHeaders ( response . getAllResponseHeaders ( ) ) ;
753+ this . SaveHttpResponseHeaders ( response ) ;
757754 }
758755
759756 /**
760757 * Save the HTTP response headers.
761758 *
762- * @param {Object } headers The response headers
759+ * @param {Object } response The response headers
763760 */
764- private SaveHttpResponseHeaders ( headers : any /* System.Net.WebHeaderCollection*/ ) : any {
761+ private SaveHttpResponseHeaders ( response : any /* System.Net.WebHeaderCollection*/ ) : any {
765762 //debug:
766763 this . httpResponseHeaders . clear ( ) ;
767764
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 ] ) ;
770767 }
771768
772769 if ( this . OnResponseHeadersCaptured != null ) {
773- this . OnResponseHeadersCaptured ( headers ) ;
770+ this . OnResponseHeadersCaptured ( this . httpResponseHeaders ) ;
774771 }
775772 }
776773
0 commit comments