Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(961)

Side by Side Diff: net/url_request/http_protocol_handler.cc

Issue 1888963004: Add HttpProtocolHandler and convert everything to use it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove-supports-scheme
Patch Set: more addressing comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/url_request/http_protocol_handler.h"
6 #include "net/url_request/url_request.h"
7 #include "net/url_request/url_request_context.h"
8 #include "net/url_request/url_request_error_job.h"
9 #include "net/url_request/url_request_http_job.h"
10 #include "net/url_request/url_request_redirect_job.h"
11 #include "url/gurl.h"
12
13 namespace net {
14
15 HttpProtocolHandler::HttpProtocolHandler() {}
16
17 URLRequestJob* HttpProtocolHandler::MaybeCreateJob(
18 URLRequest* request,
19 NetworkDelegate* network_delegate) const {
20 DCHECK(request->url().scheme() == "http" ||
21 request->url().scheme() == "https" ||
22 request->url().scheme() == "ws" || request->url().scheme() == "wss");
mmenke 2016/04/28 16:52:41 nit: While you're here, mind switching these to t
mgersh 2016/04/28 20:36:30 Done.
23
24 if (!request->context()->http_transaction_factory()) {
25 NOTREACHED() << "requires a valid context";
mmenke 2016/04/28 16:52:41 nit: include base/logging for NOTREACHED
mgersh 2016/04/28 20:36:30 Done.
26 return new URLRequestErrorJob(request, network_delegate,
27 ERR_INVALID_ARGUMENT);
mmenke 2016/04/28 16:52:41 nit: Include net/base/net_error.h
mgersh 2016/04/28 20:36:30 Done.
28 }
29
30 GURL redirect_url;
31 if (request->GetHSTSRedirect(&redirect_url)) {
32 return new URLRequestRedirectJob(
33 request, network_delegate, redirect_url,
34 // Use status code 307 to preserve the method, so POST requests work.
35 URLRequestRedirectJob::REDIRECT_307_TEMPORARY_REDIRECT, "HSTS");
36 }
37 return new URLRequestHttpJob(request, network_delegate,
38 request->context()->http_user_agent_settings());
39 }
40
41 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698