Skip to content

Commit

Permalink
Avoid sending a null type or mimeType in network responses
Browse files Browse the repository at this point in the history
DevTools refuses to show any entry that lacks the `type` property in
recent versions.  This makes it possible to inspect network responses
that for whatever reason don't have the `Content-Type` header available.

Closes facebook#57
  • Loading branch information
Josh Guilfoyle authored and longinoa committed Mar 11, 2015
1 parent 02f0b31 commit b25c2bb
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ public void responseHeadersReceived(InspectorResponse response) {
responseJSON.statusText = response.reasonPhrase();
responseJSON.headers = formatHeadersAsJSON(response);
String contentType = getContentType(response);
if (contentType != null) {
responseJSON.mimeType = getResourceTypeHelper().stripContentExtras(contentType);
}
responseJSON.mimeType = contentType != null ?
getResourceTypeHelper().stripContentExtras(contentType) :
"application/octet-stream";
responseJSON.connectionReused = response.connectionReused();
responseJSON.connectionId = response.connectionId();
responseJSON.fromDiskCache = response.fromDiskCache();
Expand All @@ -141,9 +141,9 @@ public void responseHeadersReceived(InspectorResponse response) {
receivedParams.frameId = "1";
receivedParams.loaderId = "1";
receivedParams.timestamp = stethoNow() / 1000.0;
if (contentType != null) {
receivedParams.type = getResourceTypeHelper().determineResourceType(contentType);
}
receivedParams.type = contentType != null ?
getResourceTypeHelper().determineResourceType(contentType) :
Page.ResourceType.OTHER;
receivedParams.response = responseJSON;
peerManager.sendNotificationToPeers("Network.responseReceived", receivedParams);
}
Expand Down

0 comments on commit b25c2bb

Please sign in to comment.