Skip to content

Commit 9d77f12

Browse files
author
Daniel Herzog
committed
Fixed raw mode; Tentative fix for DFL-3292: Inconsistent results for response body of redirects in Network Logger
1 parent eda0818 commit 9d77f12

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

src/network/network_details_templates.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ templates._details_content = function(entry, do_raw)
5757
responsecode = responsecode + " " + cls.ResourceUtil.http_status_codes[responsecode];
5858

5959
// Bind a template function for raw / not-raw, on demand.
60-
var template_func_name = "_requests_responses_" + do_raw ? "raw" : "not_raw" + "_bound";
60+
var template_func_name = "_requests_responses_" + (do_raw ? "raw" : "not_raw" + "_bound");
6161
if (!this[template_func_name])
6262
this[template_func_name] = this.requests_responses.bind(this, do_raw);
6363

@@ -377,7 +377,7 @@ templates._response_body = function(resp, do_raw, is_last_response)
377377
var ret = [this._wrap_pre("\n")]; // todo: no, then it's (really) empty there shouldn't be a separator either. For images it looks a bit wrong too, since the img elem makes its own space too.
378378

379379
var classname = "";
380-
if (resp.body_unavailable ||
380+
if ((resp.saw_responsefinished && resp.body_unavailable) ||
381381
!resp.responsebody && resp.is_unloaded)
382382
{
383383
classname = "network_info";

src/network/network_service.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,11 @@ cls.NetworkLoggerEntryPrototype = function()
964964
return Boolean(this._current_response && this._current_response.responsebody);
965965
});
966966

967+
this.__defineGetter__("current_response_saw_responsefinished", function()
968+
{
969+
return Boolean(this._current_response && this._current_response.saw_responsefinished);
970+
});
971+
967972
this.__defineGetter__("duration", function()
968973
{
969974
return (this.events.length && this.endtime - this.starttime) || 0;
@@ -981,6 +986,8 @@ cls.NetworkLoggerEntryPrototype = function()
981986
return Boolean(this._current_request);
982987
});
983988

989+
// todo: add empty setters.
990+
984991
};
985992

986993
cls.NetworkLoggerEntryPrototype.prototype = new URIPrototype("url");
@@ -1051,6 +1058,7 @@ cls.NetworkLoggerResponse = function(entry)
10511058
this.responsebody = null;
10521059
this.header_tokens = null; // This is set from template code, when it's first needed
10531060
this.is_response = true; // Simpler for recognizing than dealing with comparing the constructor
1061+
this.saw_responsefinished = false;
10541062

10551063
// The following are duplicated from the entry to have them available directly on the response
10561064
this.logger_entry_type = entry.type;
@@ -1078,15 +1086,22 @@ cls.NetworkLoggerResponsePrototype = function()
10781086

10791087
this._update_event_responsefinished = function(event)
10801088
{
1089+
this.saw_responsefinished = true;
10811090
if (event.data && event.data.content)
10821091
{
1092+
// event.data is of type ResourceData here.
1093+
// todo: this does not set body_unavailable = true when there is no mimeType. does that make sense?
10831094
this.responsebody = event.data;
10841095
}
10851096
};
10861097

10871098
this._update_event_responsebody = function(event)
10881099
{
1100+
// "The used mime type. This may be different from the mime type advertised in the HTTP headers."
1101+
// Todo: So this can mean that there was no response, this is better represented through "!saw_responsefinished" though,
1102+
// or that it was somehow invalid? Not so sure.
10891103
if (!event.mimeType) { this.body_unavailable = true; }
1104+
// event is of type ResourceData here.
10901105
this.responsebody = event;
10911106
// todo: check how to distinguish body_unavailable and empty body.
10921107
};
@@ -1096,7 +1111,7 @@ cls.NetworkLoggerResponsePrototype = function()
10961111
this.is_unloaded = true;
10971112
};
10981113

1099-
// The following sync changes on Entry.
1114+
// The following are to reflect changes that happened on Entry.
11001115
this._update_event_urlfinished = function(event)
11011116
{
11021117
this.logger_entry_is_finished = true;

src/network/network_view.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@ cls.NetworkLogView = function(id, name, container_class, html, default_handler)
184184
if (entry)
185185
{
186186
// todo: it would be good if we knew if the whole context is finished. Better only to get_body then, less potential to disturb.
187-
if (entry.is_finished && !entry.current_response_has_responsebody && !entry.called_get_body)
187+
if (!entry.current_response_has_responsebody &&
188+
!entry.called_get_body &&
189+
entry.is_finished &&
190+
entry.current_response_saw_responsefinished)
188191
this._service.get_body(entry.id, this.update_bound);
189192

190193
template = [template, this._render_details_view(entry)];

0 commit comments

Comments
 (0)