Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / net / tools / flip_server / spdy_util.cc
blob34b6072cfa85acb82be0e9d28d7ab4b9c5076312
1 // Copyright (c) 2009 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.
5 #include "net/tools/flip_server/spdy_util.h"
7 #include <string>
9 #include "net/tools/flip_server/url_to_filename_encoder.h"
11 namespace net {
13 bool g_need_to_encode_url = false;
15 // Encode the URL.
16 std::string EncodeURL(const std::string& uri,
17 const std::string& host,
18 const std::string& method) {
19 if (!g_need_to_encode_url) {
20 // TODO(mbelshe): if uri is fully qualified, need to strip protocol/host.
21 return std::string(method + "_" + uri);
24 std::string filename;
25 if (uri[0] == '/') {
26 // uri is not fully qualified.
27 filename = UrlToFilenameEncoder::Encode(
28 "http://" + host + uri, method + "_/", false);
29 } else {
30 filename = UrlToFilenameEncoder::Encode(uri, method + "_/", false);
32 return filename;
35 } // namespace net