incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmue...@apache.org
Subject weinre commit: handle null contentType
Date Mon, 27 Feb 2012 22:26:33 GMT
Updated Branches:
  refs/heads/master 309e7e4a3 -> e455568d9


handle null contentType

fix for https://issues.apache.org/jira/browse/CB-175
        error when XHR contentType is null

Also some drive-by fixes for contentLength


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/commit/e455568d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/tree/e455568d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/diff/e455568d

Branch: refs/heads/master
Commit: e455568d9fa924f2833a04330a3c2ea047b5a772
Parents: 309e7e4
Author: Patrick Mueller <pmuellr@apache.org>
Authored: Mon Feb 27 17:23:14 2012 -0500
Committer: Patrick Mueller <pmuellr@apache.org>
Committed: Mon Feb 27 17:23:14 2012 -0500

----------------------------------------------------------------------
 .../modules/weinre/target/NetworkRequest.coffee    |   15 ++++++++++-----
 weinre.web/modules/weinre/target/Timeline.coffee   |    7 ++++++-
 2 files changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/e455568d/weinre.web/modules/weinre/target/NetworkRequest.coffee
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/NetworkRequest.coffee b/weinre.web/modules/weinre/target/NetworkRequest.coffee
index 076fa5d..92ddee6 100644
--- a/weinre.web/modules/weinre/target/NetworkRequest.coffee
+++ b/weinre.web/modules/weinre/target/NetworkRequest.coffee
@@ -120,15 +120,15 @@ getRequest = (url, method, xhr, data) ->
 
 #-------------------------------------------------------------------------------
 getResponse = (xhr) ->
-    contentType = xhr.getResponseHeader("Content-Type")
+    contentType = xhr.getResponseHeader("Content-Type") 
+    contentType ||= 'application/octet-stream'
 
     [contentType, encoding] = splitContentType(contentType)
 
     headers = getHeaders(xhr)
 
-    return {
-        mimeType: contentType
-        expectedContentLength: contentType
+    result = 
+        mimeType:              contentType
         textEncodingName:      encoding
         httpStatusCode:        xhr.status
         httpStatusText:        xhr.statusText
@@ -136,7 +136,12 @@ getResponse = (xhr) ->
         connectionReused:      false
         connectionID:          0
         wasCached:             false
-    }
+    
+    contentLength = xhr.getResponseHeader("Content-Length")
+    contentLength = parseInt(contentLength)
+    result.expectedContentLength = contentLength if !isNaN(contentLength)
+
+    return result
 
 #-------------------------------------------------------------------------------
 getHeaders = (xhr) ->

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/e455568d/weinre.web/modules/weinre/target/Timeline.coffee
----------------------------------------------------------------------
diff --git a/weinre.web/modules/weinre/target/Timeline.coffee b/weinre.web/modules/weinre/target/Timeline.coffee
index a66dfed..fdf93d5 100644
--- a/weinre.web/modules/weinre/target/Timeline.coffee
+++ b/weinre.web/modules/weinre/target/Timeline.coffee
@@ -154,6 +154,9 @@ module.exports = class Timeline
         record.startTime = Date.now()
         record.category  = name: "loading"
 
+        contentLength = xhr.getResponseHeader("Content-Length")
+        contentLength = parseInt(contentLength)
+
         if xhr.readyState == XMLHttpRequest.OPENED
             record.type = TimelineRecordType.ResourceSendRequest
             record.data =
@@ -167,8 +170,10 @@ module.exports = class Timeline
                 identifier:            id
                 statusCode:            xhr.status
                 mimeType:              xhr.getResponseHeader("Content-Type")
-                expectedContentLength: xhr.getResponseHeader("Content-Length")
                 url:                   url
+
+            record.data.expectedContentLength = contentLength if !isNaN(contentLength)
+
         else
             return
 


Mime
View raw message