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

Side by Side Diff: cloud_print/gcp20/prototype/privet_http_server.cc

Issue 735053002: Prefix CommandLine usage with base namespace (Part 7: cloud_print/) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « cloud_print/gcp20/prototype/printer.cc ('k') | cloud_print/service/win/chrome_launcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cloud_print/gcp20/prototype/privet_http_server.h" 5 #include "cloud_print/gcp20/prototype/privet_http_server.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "cloud_print/gcp20/prototype/gcp20_switches.h" 10 #include "cloud_print/gcp20/prototype/gcp20_switches.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 132 }
133 133
134 void PrivetHttpServer::OnHttpRequest(int connection_id, 134 void PrivetHttpServer::OnHttpRequest(int connection_id,
135 const net::HttpServerRequestInfo& info) { 135 const net::HttpServerRequestInfo& info) {
136 VLOG(1) << "Processing HTTP request: " << info.path; 136 VLOG(1) << "Processing HTTP request: " << info.path;
137 GURL url("http://host" + info.path); 137 GURL url("http://host" + info.path);
138 138
139 if (!ValidateRequestMethod(connection_id, url.path(), info.method)) 139 if (!ValidateRequestMethod(connection_id, url.path(), info.method))
140 return; 140 return;
141 141
142 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableXTocken)) { 142 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
143 switches::kDisableXTocken)) {
143 net::HttpServerRequestInfo::HeadersMap::const_iterator iter = 144 net::HttpServerRequestInfo::HeadersMap::const_iterator iter =
144 info.headers.find("x-privet-token"); 145 info.headers.find("x-privet-token");
145 if (iter == info.headers.end()) { 146 if (iter == info.headers.end()) {
146 server_->Send(connection_id, net::HTTP_BAD_REQUEST, 147 server_->Send(connection_id, net::HTTP_BAD_REQUEST,
147 "Missing X-Privet-Token header.\n" 148 "Missing X-Privet-Token header.\n"
148 "TODO: Message should be in header, not in the body!", 149 "TODO: Message should be in header, not in the body!",
149 "text/plain"); 150 "text/plain");
150 return; 151 return;
151 } 152 }
152 153
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 bool PrivetHttpServer::ValidateRequestMethod(int connection_id, 186 bool PrivetHttpServer::ValidateRequestMethod(int connection_id,
186 const std::string& request, 187 const std::string& request,
187 const std::string& method) { 188 const std::string& method) {
188 DCHECK(!IsGetMethod(request) || !IsPostMethod(request)); 189 DCHECK(!IsGetMethod(request) || !IsPostMethod(request));
189 190
190 if (!IsGetMethod(request) && !IsPostMethod(request)) { 191 if (!IsGetMethod(request) && !IsPostMethod(request)) {
191 server_->Send404(connection_id); 192 server_->Send404(connection_id);
192 return false; 193 return false;
193 } 194 }
194 195
195 if (CommandLine::ForCurrentProcess()->HasSwitch("disable-method-check")) 196 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
197 "disable-method-check"))
196 return true; 198 return true;
197 199
198 if ((IsGetMethod(request) && method != "GET") || 200 if ((IsGetMethod(request) && method != "GET") ||
199 (IsPostMethod(request) && method != "POST")) { 201 (IsPostMethod(request) && method != "POST")) {
200 ReportInvalidMethod(connection_id); 202 ReportInvalidMethod(connection_id);
201 return false; 203 return false;
202 } 204 }
203 205
204 return true; 206 return true;
205 } 207 }
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 delegate_->GetRegistrationServerError(&description); 502 delegate_->GetRegistrationServerError(&description);
501 *current_response = CreateErrorWithDescription("server_error", 503 *current_response = CreateErrorWithDescription("server_error",
502 description); 504 description);
503 break; 505 break;
504 } 506 }
505 507
506 default: 508 default:
507 NOTREACHED(); 509 NOTREACHED();
508 }; 510 };
509 } 511 }
OLDNEW
« no previous file with comments | « cloud_print/gcp20/prototype/printer.cc ('k') | cloud_print/service/win/chrome_launcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698