From 48ca92fdf7cb0d89d9760fce2cdc85dd22d8d3fd Mon Sep 17 00:00:00 2001 From: mguessan Date: Tue, 4 Nov 2008 10:37:36 +0000 Subject: [PATCH] Optimize Http requests on session creation git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@161 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- src/java/davmail/exchange/ExchangeSession.java | 7 ++++--- src/java/davmail/exchange/ExchangeSessionFactory.java | 1 + src/java/davmail/http/DavGatewayHttpClientFacade.java | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/java/davmail/exchange/ExchangeSession.java b/src/java/davmail/exchange/ExchangeSession.java index 43606a90..b584554b 100644 --- a/src/java/davmail/exchange/ExchangeSession.java +++ b/src/java/davmail/exchange/ExchangeSession.java @@ -260,14 +260,15 @@ public class ExchangeSession { // get webmail root url // providing credentials // manually follow redirect - HttpMethod initmethod = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, baseUrl); + HttpMethod method = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, baseUrl); if (!isBasicAuthentication) { - formLogin(httpClient, initmethod, userName, password); + formLogin(httpClient, method, userName, password); + // reexecute method with new base URL + method = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, baseUrl); } // User may be authenticated, get various session information - HttpMethod method = DavGatewayHttpClientFacade.executeFollowRedirects(httpClient, baseUrl); int status = method.getStatusCode(); if (status != HttpStatus.SC_OK) { HttpException ex = new HttpException(); diff --git a/src/java/davmail/exchange/ExchangeSessionFactory.java b/src/java/davmail/exchange/ExchangeSessionFactory.java index 954c4ebb..72baa643 100644 --- a/src/java/davmail/exchange/ExchangeSessionFactory.java +++ b/src/java/davmail/exchange/ExchangeSessionFactory.java @@ -50,6 +50,7 @@ public class ExchangeSessionFactory { // get webmail root url (will not follow redirects) testMethod.setFollowRedirects(false); + testMethod.setDoAuthentication(false); int status = httpClient.executeMethod(testMethod); testMethod.releaseConnection(); ExchangeSession.LOGGER.debug("Test configuration status: " + status); diff --git a/src/java/davmail/http/DavGatewayHttpClientFacade.java b/src/java/davmail/http/DavGatewayHttpClientFacade.java index fe0ce553..7d433956 100644 --- a/src/java/davmail/http/DavGatewayHttpClientFacade.java +++ b/src/java/davmail/http/DavGatewayHttpClientFacade.java @@ -88,6 +88,7 @@ public class DavGatewayHttpClientFacade { int status = 0; HttpClient httpClient = DavGatewayHttpClientFacade.getInstance(); HttpMethod testMethod = new GetMethod(url); + testMethod.setDoAuthentication(false); try { status = httpClient.executeMethod(testMethod); } finally {