Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / net / tools / flip_server / spdy_util.cc
bloba8cbd683dcdc577369c347fd7529abfeaf6f112d
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(std::string uri, std::string host, std::string method) {
17 if (!g_need_to_encode_url) {
18 // TODO(mbelshe): if uri is fully qualified, need to strip protocol/host.
19 return std::string(method + "_" + uri);
22 std::string filename;
23 if (uri[0] == '/') {
24 // uri is not fully qualified.
25 filename = UrlToFilenameEncoder::Encode(
26 "http://" + host + uri, method + "_/", false);
27 } else {
28 filename = UrlToFilenameEncoder::Encode(uri, method + "_/", false);
30 return filename;
33 } // namespace net