|
@@ -5,6 +5,7 @@
|
|
|
#include "atom/browser/net/atom_network_delegate.h"
|
|
|
|
|
|
#include <string>
|
|
|
+#include <utility>
|
|
|
|
|
|
#include "atom/common/native_mate_converters/net_converter.h"
|
|
|
#include "base/stl_util.h"
|
|
@@ -19,6 +20,9 @@ namespace atom {
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
+using ResponseHeadersContainer =
|
|
|
+ std::pair<scoped_refptr<net::HttpResponseHeaders>*, const std::string&>;
|
|
|
+
|
|
|
const char* ResourceTypeToString(content::ResourceType type) {
|
|
|
switch (type) {
|
|
|
case content::RESOURCE_TYPE_MAIN_FRAME:
|
|
@@ -170,16 +174,19 @@ void ReadFromResponseObject(const base::DictionaryValue& response,
|
|
|
}
|
|
|
|
|
|
void ReadFromResponseObject(const base::DictionaryValue& response,
|
|
|
- scoped_refptr<net::HttpResponseHeaders>* headers) {
|
|
|
+ const ResponseHeadersContainer& container) {
|
|
|
const base::DictionaryValue* dict;
|
|
|
+ std::string status_line;
|
|
|
+ if (!response.GetString("statusLine", &status_line))
|
|
|
+ status_line = container.second;
|
|
|
if (response.GetDictionary("responseHeaders", &dict)) {
|
|
|
+ auto headers = container.first;
|
|
|
*headers = new net::HttpResponseHeaders("");
|
|
|
+ (*headers)->ReplaceStatusLine(status_line);
|
|
|
for (base::DictionaryValue::Iterator it(*dict);
|
|
|
!it.IsAtEnd();
|
|
|
it.Advance()) {
|
|
|
const base::ListValue* list;
|
|
|
- if (base::ToLowerASCII(it.key()) == "location")
|
|
|
- (*headers)->ReplaceStatusLine("HTTP/1.1 302 Found");
|
|
|
if (it.value().GetAsList(&list)) {
|
|
|
(*headers)->RemoveHeader(it.key());
|
|
|
for (size_t i = 0; i < list->GetSize(); ++i) {
|
|
@@ -265,7 +272,8 @@ int AtomNetworkDelegate::OnHeadersReceived(
|
|
|
request, callback, original, override, allowed);
|
|
|
|
|
|
return HandleResponseEvent(
|
|
|
- kOnHeadersReceived, request, callback, override, original);
|
|
|
+ kOnHeadersReceived, request, callback,
|
|
|
+ std::make_pair(override, original->GetStatusLine()), original);
|
|
|
}
|
|
|
|
|
|
void AtomNetworkDelegate::OnBeforeRedirect(net::URLRequest* request,
|