From 05dfc20853503d1bc5bb13201b4f9e6db1da856d Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Thu, 29 Oct 2009 20:03:01 -0700 Subject: [PATCH] Fix #2225869 (Regression in attachment loading / Exchange 2003) * The fix to bug #2191778 inadvertently broke attachment loading for Exchange 2003 servers; the server responds with a 403 error (indicating an authentication issue) * All other communications with the server work properly * We use a slightly different set of calls in the case of attachments (we wanted to change as little as possible in the fix to #2191778) than we do in the other cases * The fix here is to use the same calling sequence for attachments that we use elsewhere * This fix has been observed to work on multiple servers, and in various SSL scenarios (on/off, trusted/untrusted) Change-Id: Ie2804ddcbfa2b10edff42f7a3811734c325e933d --- src/com/android/exchange/EasSyncService.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/com/android/exchange/EasSyncService.java b/src/com/android/exchange/EasSyncService.java index 0f2a34594..54e426429 100644 --- a/src/com/android/exchange/EasSyncService.java +++ b/src/com/android/exchange/EasSyncService.java @@ -295,12 +295,10 @@ public class EasSyncService extends AbstractSyncService { Attachment att = req.att; Message msg = Message.restoreMessageWithId(mContext, att.mMessageKey); doProgressCallback(msg.mId, att.mId, 0); - HttpClient client = getHttpClient(COMMAND_TIMEOUT); - String us = makeUriString("GetAttachment", "&AttachmentName=" + att.mLocation); - HttpPost method = new HttpPost(URI.create(us)); - method.setHeader("Authorization", mAuthString); - HttpResponse res = client.execute(method); + String cmd = "GetAttachment&AttachmentName=" + att.mLocation; + HttpResponse res = sendHttpClientPost(cmd, null, COMMAND_TIMEOUT); + int status = res.getStatusLine().getStatusCode(); if (status == HttpStatus.SC_OK) { HttpEntity e = res.getEntity(); @@ -428,9 +426,11 @@ public class EasSyncService extends AbstractSyncService { String us = makeUriString(cmd, extra); HttpPost method = new HttpPost(URI.create(us)); + // Send the proper Content-Type header + // If entity is null (e.g. for attachments), don't set this header if (msg) { method.setHeader("Content-Type", "message/rfc822"); - } else { + } else if (entity != null) { method.setHeader("Content-Type", "application/vnd.ms-sync.wbxml"); } setHeaders(method);