From 1605400e1ec42d1fc39c2158e9d7739b78da839f Mon Sep 17 00:00:00 2001 From: mguessan Date: Tue, 14 May 2013 08:25:37 +0000 Subject: [PATCH] EWS: Fix regression in checkEndPointUrl, get /ews/services.wsdl git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@2117 3d1905a2-6b24-0410-a738-b14d5a86fcbd --- .../exchange/ews/EwsExchangeSession.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/java/davmail/exchange/ews/EwsExchangeSession.java b/src/java/davmail/exchange/ews/EwsExchangeSession.java index 62e9a8db..db5ceacd 100644 --- a/src/java/davmail/exchange/ews/EwsExchangeSession.java +++ b/src/java/davmail/exchange/ews/EwsExchangeSession.java @@ -163,22 +163,18 @@ public class EwsExchangeSession extends ExchangeSession { * @throws IOException on error */ protected void checkEndPointUrl(String endPointUrl) throws IOException { - HttpMethod getMethod = new HeadMethod(endPointUrl); - getMethod.setFollowRedirects(false); + HttpMethod checkMethod = new HeadMethod(endPointUrl); + checkMethod.setPath("/ews/services.wsdl"); + checkMethod.setFollowRedirects(false); try { - int status = DavGatewayHttpClientFacade.executeNoRedirect(httpClient, getMethod); + int status = DavGatewayHttpClientFacade.executeNoRedirect(httpClient, checkMethod); if (status == HttpStatus.SC_UNAUTHORIZED) { throw new DavMailAuthenticationException("EXCEPTION_AUTHENTICATION_FAILED"); - } else if (status != HttpStatus.SC_MOVED_TEMPORARILY) { - throw DavGatewayHttpClientFacade.buildHttpException(getMethod); - } - // check Location - Header locationHeader = getMethod.getResponseHeader("Location"); - if (locationHeader == null || !"/ews/services.wsdl".equalsIgnoreCase(locationHeader.getValue())) { - throw new IOException("Ews endpoint not available at " + getMethod.getURI().toString()); + } else if (status != HttpStatus.SC_OK) { + throw new IOException("Ews endpoint not available at " + checkMethod.getURI().toString()+" status "+status); } } finally { - getMethod.releaseConnection(); + checkMethod.releaseConnection(); } }