BrowserThread::GetBlockingPool()->GetTaskRunnerWithShutdownBehavior(
base::SequencedWorkerPool::SKIP_ON_SHUTDOWN)));
job_factory->SetProtocolHandler(
- url::kHttpScheme, new HttpProtocolHandler());
+ url::kHttpScheme, new HttpProtocolHandler(url::kHttpScheme));
+ job_factory->SetProtocolHandler(
+ url::kHttpsScheme, new HttpProtocolHandler(url::kHttpsScheme));
+ job_factory->SetProtocolHandler(
+ url::kWsScheme, new HttpProtocolHandler(url::kWsScheme));
+ job_factory->SetProtocolHandler(
+ url::kWssScheme, new HttpProtocolHandler(url::kWssScheme));
// Set up interceptors in the reverse order.
scoped_ptr<net::URLRequestJobFactory> top_job_factory = job_factory.Pass();
namespace atom {
-HttpProtocolHandler::HttpProtocolHandler() {
+HttpProtocolHandler::HttpProtocolHandler(const std::string& scheme)
+ : scheme_(scheme) {
}
HttpProtocolHandler::~HttpProtocolHandler() {
net::NetworkDelegate* network_delegate) const {
return net::URLRequestHttpJob::Factory(request,
network_delegate,
- "http");
+ scheme_);
}
} // namespace atom
#ifndef ATOM_BROWSER_NET_HTTP_PROTOCOL_HANDLER_H_
#define ATOM_BROWSER_NET_HTTP_PROTOCOL_HANDLER_H_
+#include <string>
+
#include "net/url_request/url_request_job_factory.h"
namespace atom {
class HttpProtocolHandler : public net::URLRequestJobFactory::ProtocolHandler {
public:
- HttpProtocolHandler();
+ explicit HttpProtocolHandler(const std::string&);
virtual ~HttpProtocolHandler();
// net::URLRequestJobFactory::ProtocolHandler:
net::URLRequestJob* MaybeCreateJob(
net::URLRequest* request,
net::NetworkDelegate* network_delegate) const override;
+
+ private:
+ std::string scheme_;
};
} // namespace atom
protocol.uninterceptProtocol 'http'
done()
protocol.interceptProtocol 'http', handler
+
+ it 'can override https protocol handler', (done) ->
+ handler = remote.createFunctionWithReturnValue 'valar morghulis'
+ protocol.once 'intercepted', ->
+ protocol.uninterceptProtocol 'https'
+ done()
+ protocol.interceptProtocol 'https', handler
+
+ it 'can override ws protocol handler', (done) ->
+ handler = remote.createFunctionWithReturnValue 'valar morghulis'
+ protocol.once 'intercepted', ->
+ protocol.uninterceptProtocol 'ws'
+ done()
+ protocol.interceptProtocol 'ws', handler
+
+ it 'can override wss protocol handler', (done) ->
+ handler = remote.createFunctionWithReturnValue 'valar morghulis'
+ protocol.once 'intercepted', ->
+ protocol.uninterceptProtocol 'wss'
+ done()
+ protocol.interceptProtocol 'wss', handler