Hello nicolasroard, steveblock,

I'd like you to do a code review.  Please execute
        g4 diff -c 9194769

or point your web browser to
        http://mondrian/9194769

to review the following code:

Change 9194769 by [EMAIL PROTECTED] on 2008/11/28 15:30:38 *pending*

        Fix a bug with the way the content type header is handled in
        Android HttpRequest. The real fix is on the Java side but we
        need to work around it on the C++ side at this moment.
        
        PRESUBMIT=passed
        R=nicolasroard,steveblock
        [EMAIL PROTECTED]
        DELTA=20  (19 added, 0 deleted, 1 changed)
        OCL=9194769

Affected files ...

... 
//depot/googleclient/gears/opensource/gears/localserver/android/http_request_android.cc#3
 edit

20 delta lines: 19 added, 0 deleted, 1 changed

Also consider running:
        g4 lint -c 9194769

which verifies that the changelist doesn't introduce new style violations.

If you can't do the review, please let me know as soon as possible.  During
your review, please ensure that all new code has corresponding unit tests and
that existing unit tests are updated appropriately.  Visit
http://www/eng/code_review.html for more information.

This is a semiautomated message from "g4 mail".  Complaints or suggestions?
Mail [EMAIL PROTECTED]
Change 9194769 by [EMAIL PROTECTED] on 2008/11/28 15:30:38 *pending*

        Fix a bug with the way the content type header is handled in Android 
HttpRequest. The real fix is on the Java side but we need to work around it on 
the C++ side at this moment.

Affected files ...

... 
//depot/googleclient/gears/opensource/gears/localserver/android/http_request_android.cc#3
 edit

==== 
//depot/googleclient/gears/opensource/gears/localserver/android/http_request_android.cc#3
 - 
/home/andreip/Gears/googleclient/gears/opensource/gears/localserver/android/http_request_android.cc
 ====
# action=edit type=text
--- 
googleclient/gears/opensource/gears/localserver/android/http_request_android.cc 
    2008-11-28 15:32:25.000000000 +0000
+++ 
googleclient/gears/opensource/gears/localserver/android/http_request_android.cc 
    2008-11-28 15:28:27.000000000 +0000
@@ -44,6 +44,7 @@
 #include "gears/base/common/http_utils.h"
 #include "gears/base/common/message_queue.h"
 #include "gears/base/common/security_model.h"
+#include "gears/base/common/string_utils.h"
 #include "gears/base/common/url_utils.h"
 #include "gears/base/npapi/browser_utils.h"
 #include "gears/localserver/common/safe_http_request.h"
@@ -57,6 +58,12 @@
 // Default encoding for a document which doesn't specify it. RFC-2616
 // states there is no default.
 static const char16 *const kDefaultEncoding = STRING16(L"");
+
+// Currently, HttpRequestAndroid::synthesizeHeadersFromCacheResult()
+// may insert a spurious string at the end of the contentType header.
+// We need to remove it if it's present.
+static const char16 *const kEncodingSillyBug = STRING16(L"; charset=");
+
 
 // Number of bytes to send or receive in one go.
 static const int kTransferSize = 4096;
@@ -1290,13 +1297,25 @@
   // Get a single response header. This is implemented on the Java
   // side.
   assert(IsMainThread());
+  assert(name);
+  assert(value);
   JavaLocalFrame frame;
   jobject result = JniGetEnv()->CallObjectMethod(
       java_object_.Get(),
       GetMethod(JAVA_METHOD_GET_RESPONSE_HEADER),
       JavaString(name).Get());
   if (result != NULL) {
-    return JavaString(static_cast<jstring>(result)).ToString16(value);
+    std::string16 local_value;
+    JavaString(static_cast<jstring>(result)).ToString16(&local_value);
+    // Now check for the spurious '; charset=' string at the end.
+    // TODO(andreip): remove this once the bug is fixed on the Java side.
+    std::string16 content_type_name(HttpConstants::kContentTypeHeader);
+    if (content_type_name == name &&
+        EndsWithIgnoreCase(local_value, std::string16(kEncodingSillyBug))) {
+      local_value = local_value.substr(0, 
local_value.rfind(kEncodingSillyBug));
+    }
+    *value = local_value;
+    return true;
   } else {
     value->clear();
     return true;

Reply via email to