#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/net/atom_url_request_job_factory.h"
#include "atom/browser/net/asar/asar_protocol_handler.h"
+#include "atom/browser/net/http_protocol_handler.h"
#include "atom/browser/web_view_manager.h"
#include "atom/common/options_switches.h"
#include "base/command_line.h"
url::kFileScheme, new asar::AsarProtocolHandler(
BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
+ job_factory->SetProtocolHandler(
+ url::kHttpScheme, new HttpProtocolHandler());
// Set up interceptors in the reverse order.
scoped_ptr<net::URLRequestJobFactory> top_job_factory = job_factory.Pass();
--- /dev/null
+// Copyright (c) 2015 GitHub, Inc.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+
+#include "atom/browser/net/http_protocol_handler.h"
+
+#include "net/url_request/url_request_http_job.h"
+
+namespace atom {
+
+HttpProtocolHandler::HttpProtocolHandler() {
+}
+
+HttpProtocolHandler::~HttpProtocolHandler() {
+}
+
+net::URLRequestJob* HttpProtocolHandler::MaybeCreateJob(
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate) const {
+ return net::URLRequestHttpJob::Factory(request,
+ network_delegate,
+ "http");
+}
+
+} // namespace atom
--- /dev/null
+// Copyright (c) 2015 GitHub, Inc.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+
+#ifndef ATOM_BROWSER_NET_HTTP_PROTOCOL_HANDLER_H_
+#define ATOM_BROWSER_NET_HTTP_PROTOCOL_HANDLER_H_
+
+#include "net/url_request/url_request_job_factory.h"
+
+namespace atom {
+
+class HttpProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler {
+ public:
+ HttpProtocolHandler();
+ virtual ~HttpProtocolHandler();
+
+ // net::URLRequestJobFactory::ProtocolHandler:
+ net::URLRequestJob* MaybeCreateJob(
+ net::URLRequest* request,
+ net::NetworkDelegate* network_delegate) const override;
+};
+
+} // namespace atom
+
+#endif // ATOM_BROWSER_NET_HTTP_PROTOCOL_HANDLER_H_
'atom/browser/net/asar/url_request_asar_job.h',
'atom/browser/net/atom_url_request_job_factory.cc',
'atom/browser/net/atom_url_request_job_factory.h',
+ 'atom/browser/net/http_protocol_handler.cc',
+ 'atom/browser/net/http_protocol_handler.h',
'atom/browser/net/url_request_string_job.cc',
'atom/browser/net/url_request_string_job.h',
'atom/browser/net/url_request_buffer_job.cc',
assert false, 'Got error: ' + errorType + ' ' + error
free()
protocol.interceptProtocol 'file', handler
+
+ it 'can override http protocol handler', (done) ->
+ handler = remote.createFunctionWithReturnValue 'valar morghulis'
+ protocol.once 'intercepted', ->
+ protocol.uninterceptProtocol 'http'
+ done()
+ protocol.interceptProtocol 'http', handler