]> khamidou — GitHub mirrors - electron.git/commitdiff
Always set headers for response
authorCheng Zhao <zcbenz@gmail.com>
Thu, 13 Aug 2015 14:26:27 +0000 (22:26 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 13 Aug 2015 14:26:27 +0000 (22:26 +0800)
When intercepting HTTP protocols Chromium will assume there is always headers
set, so we have to provide headers for all the responses to avoid the
crash.

atom/browser/net/js_asker.h

index 63b3199890c6871f321d973bf5d0a4f3fcbead6e..9c45446abcbb11ff764147131d16a9eed5b72341 100644 (file)
@@ -11,6 +11,7 @@
 #include "base/values.h"
 #include "content/public/browser/browser_thread.h"
 #include "net/base/net_errors.h"
+#include "net/http/http_response_headers.h"
 #include "net/url_request/url_request_context_getter.h"
 #include "net/url_request/url_request_job.h"
 #include "v8/include/v8.h"
@@ -71,6 +72,9 @@ class JsAsker : public RequestJob {
                    base::Bind(&JsAsker::OnResponse,
                               weak_factory_.GetWeakPtr())));
   }
+  void GetResponseInfo(net::HttpResponseInfo* info) override {
+    info->headers = new net::HttpResponseHeaders("");
+  }
 
   // Called when the JS handler has sent the response, we need to decide whether
   // to start, or fail the job.