| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 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 "net/tools/flip_server/spdy_util.h" | 5 #include "net/tools/flip_server/spdy_util.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "net/tools/flip_server/url_to_filename_encoder.h" | 9 #include "net/tools/flip_server/url_to_filename_encoder.h" |
| 10 | 10 |
| 11 namespace net { | 11 namespace net { |
| 12 | 12 |
| 13 bool g_need_to_encode_url = false; | 13 bool g_need_to_encode_url = false; |
| 14 | 14 |
| 15 // Encode the URL. | 15 // Encode the URL. |
| 16 std::string EncodeURL(std::string uri, std::string host, std::string method) { | 16 std::string EncodeURL(const std::string& uri, |
| 17 const std::string& host, |
| 18 const std::string& method) { |
| 17 if (!g_need_to_encode_url) { | 19 if (!g_need_to_encode_url) { |
| 18 // TODO(mbelshe): if uri is fully qualified, need to strip protocol/host. | 20 // TODO(mbelshe): if uri is fully qualified, need to strip protocol/host. |
| 19 return std::string(method + "_" + uri); | 21 return std::string(method + "_" + uri); |
| 20 } | 22 } |
| 21 | 23 |
| 22 std::string filename; | 24 std::string filename; |
| 23 if (uri[0] == '/') { | 25 if (uri[0] == '/') { |
| 24 // uri is not fully qualified. | 26 // uri is not fully qualified. |
| 25 filename = UrlToFilenameEncoder::Encode( | 27 filename = UrlToFilenameEncoder::Encode( |
| 26 "http://" + host + uri, method + "_/", false); | 28 "http://" + host + uri, method + "_/", false); |
| 27 } else { | 29 } else { |
| 28 filename = UrlToFilenameEncoder::Encode(uri, method + "_/", false); | 30 filename = UrlToFilenameEncoder::Encode(uri, method + "_/", false); |
| 29 } | 31 } |
| 30 return filename; | 32 return filename; |
| 31 } | 33 } |
| 32 | 34 |
| 33 } // namespace net | 35 } // namespace net |
| OLD | NEW |