mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-12 14:08:38 -05:00
Force internet explorer header to get XML responses
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@184 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
1f5eb0d983
commit
39d4bafb91
@ -119,9 +119,9 @@ public class DavGateway {
|
||||
public static String getReleasedVersion() {
|
||||
String version = null;
|
||||
BufferedReader versionReader = null;
|
||||
HttpClient httpClient = DavGatewayHttpClientFacade.getInstance();
|
||||
GetMethod getMethod = new GetMethod("http://davmail.sourceforge.net/version.txt");
|
||||
try {
|
||||
HttpClient httpClient = DavGatewayHttpClientFacade.getInstance();
|
||||
httpClient.setConnectionTimeout(250);
|
||||
int status = httpClient.executeMethod(getMethod);
|
||||
if (status == HttpStatus.SC_OK) {
|
||||
|
@ -1,16 +1,9 @@
|
||||
package davmail.exchange;
|
||||
|
||||
import davmail.Settings;
|
||||
import davmail.tray.DavGatewayTray;
|
||||
import davmail.http.DavGatewayHttpClientFacade;
|
||||
import org.apache.commons.httpclient.Header;
|
||||
import org.apache.commons.httpclient.HttpClient;
|
||||
import org.apache.commons.httpclient.HttpException;
|
||||
import org.apache.commons.httpclient.HttpMethod;
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.HttpURL;
|
||||
import org.apache.commons.httpclient.HttpsURL;
|
||||
import org.apache.commons.httpclient.URIException;
|
||||
import davmail.tray.DavGatewayTray;
|
||||
import org.apache.commons.httpclient.*;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.apache.commons.httpclient.methods.PostMethod;
|
||||
import org.apache.commons.httpclient.methods.PutMethod;
|
||||
@ -20,13 +13,12 @@ import org.apache.webdav.lib.Property;
|
||||
import org.apache.webdav.lib.ResponseEntity;
|
||||
import org.apache.webdav.lib.WebdavResource;
|
||||
import org.apache.webdav.lib.methods.SearchMethod;
|
||||
import org.apache.webdav.lib.methods.PropFindMethod;
|
||||
|
||||
import javax.mail.internet.MimeUtility;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamConstants;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
@ -973,8 +965,6 @@ public class ExchangeSession {
|
||||
public String getEmail() throws IOException {
|
||||
String email = null;
|
||||
GetMethod getMethod = new GetMethod("/public/?Cmd=galfind&AN=" + getUserName());
|
||||
// force XML response with Internet Explorer header
|
||||
getMethod.setRequestHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)");
|
||||
XMLStreamReader reader = null;
|
||||
try {
|
||||
int status = wdr.retrieveSessionInstance().executeMethod(getMethod);
|
||||
@ -1057,7 +1047,6 @@ public class ExchangeSession {
|
||||
}
|
||||
|
||||
GetMethod getMethod = new GetMethod(url);
|
||||
getMethod.setRequestHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)");
|
||||
getMethod.setRequestHeader("Content-Type", "text/xml");
|
||||
|
||||
try {
|
||||
|
@ -42,12 +42,9 @@ public class ExchangeSessionFactory {
|
||||
|
||||
public static void checkConfig() throws IOException {
|
||||
String url = Settings.getProperty("davmail.url");
|
||||
HttpClient httpClient = DavGatewayHttpClientFacade.getInstance();
|
||||
HttpMethod testMethod = new GetMethod(url);
|
||||
try {
|
||||
|
||||
// create an HttpClient instance
|
||||
HttpClient httpClient = DavGatewayHttpClientFacade.getInstance();
|
||||
|
||||
// get webmail root url (will not follow redirects)
|
||||
testMethod.setFollowRedirects(false);
|
||||
testMethod.setDoAuthentication(false);
|
||||
|
@ -16,6 +16,11 @@ import java.io.IOException;
|
||||
* Create HttpClient instance according to DavGateway Settings
|
||||
*/
|
||||
public class DavGatewayHttpClientFacade {
|
||||
static {
|
||||
// force XML response with Internet Explorer header
|
||||
System.getProperties().setProperty("httpclient.useragent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a configured HttpClient instance.
|
||||
*
|
||||
@ -34,6 +39,7 @@ public class DavGatewayHttpClientFacade {
|
||||
* @param httpClient current Http client
|
||||
*/
|
||||
public static void configureClient(HttpClient httpClient) {
|
||||
|
||||
// do not send basic auth automatically
|
||||
httpClient.getState().setAuthenticationPreemptive(false);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user