1
0
mirror of https://github.com/etesync/android synced 2024-11-26 09:58:11 +00:00

don't follow redirects (see issue #52)

This commit is contained in:
rfc2822 2013-10-30 17:20:04 +01:00
parent dbc89cb4fe
commit a45aed6914
2 changed files with 11 additions and 3 deletions

View File

@ -246,7 +246,7 @@ public class LocalCalendar extends LocalCollection<Event> {
try { try {
e.setOrganizer(new Organizer("mailto:" + cursor.getString(15))); e.setOrganizer(new Organizer("mailto:" + cursor.getString(15)));
} catch (URISyntaxException ex) { } catch (URISyntaxException ex) {
Log.e(TAG, "Error parsing organizer email address, ignoring"); Log.e(TAG, "Error parsing organizer URI, ignoring");
} }
Uri attendeesUri = Attendees.CONTENT_URI.buildUpon() Uri attendeesUri = Attendees.CONTENT_URI.buildUpon()

View File

@ -32,12 +32,14 @@ import org.apache.http.client.methods.HttpDelete;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpOptions; import org.apache.http.client.methods.HttpOptions;
import org.apache.http.client.methods.HttpPut; import org.apache.http.client.methods.HttpPut;
import org.apache.http.client.params.ClientPNames;
import org.apache.http.entity.ByteArrayEntity; import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.EnglishReasonPhraseCatalog; import org.apache.http.impl.EnglishReasonPhraseCatalog;
import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.CoreProtocolPNames; import org.apache.http.params.CoreProtocolPNames;
import android.util.Log; import android.util.Log;
import at.bitfire.davdroid.Constants;
@ToString @ToString
@ -71,18 +73,24 @@ public class WebDavResource {
if (isCollection && !location.getPath().endsWith("/")) if (isCollection && !location.getPath().endsWith("/"))
location = new URI(location.getScheme(), location.getSchemeSpecificPart() + "/", null); location = new URI(location.getScheme(), location.getSchemeSpecificPart() + "/", null);
// create new HTTP client
client = new DefaultHttpClient(); client = new DefaultHttpClient();
client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "DAVdroid/" + Constants.APP_VERSION);
// authenticate
client.getCredentialsProvider().setCredentials(new AuthScope(location.getHost(), location.getPort()), client.getCredentialsProvider().setCredentials(new AuthScope(location.getHost(), location.getPort()),
new UsernamePasswordCredentials(username, password)); new UsernamePasswordCredentials(username, password));
// preemptive auth is available for Basic auth only // preemptive auth is available for Basic auth only
if (preemptive) { if (preemptive) {
Log.i(TAG, "Using preemptive Basic Authentication"); Log.i(TAG, "Using preemptive Basic Authentication");
client.addRequestInterceptor(new PreemptiveAuthInterceptor(), 0); client.addRequestInterceptor(new PreemptiveAuthInterceptor(), 0);
} }
client.getParams().setParameter(CoreProtocolPNames.USER_AGENT, "DAVdroid"); // allow gzip compression
GzipDecompressingEntity.enable(client); GzipDecompressingEntity.enable(client);
// redirections
client.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);
} }
protected WebDavResource(WebDavCollection parent, URI uri) { protected WebDavResource(WebDavCollection parent, URI uri) {