OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/base/host_port_pair.h" | 5 #include "net/base/host_port_pair.h" |
6 #include "base/string_util.h" | 6 #include "base/string_util.h" |
7 | 7 |
8 namespace net { | 8 namespace net { |
9 | 9 |
| 10 HostPortPair::HostPortPair() : port(0) {} |
| 11 HostPortPair::HostPortPair(const std::string& in_host, uint16 in_port) |
| 12 : host(in_host), port(in_port) {} |
| 13 |
10 std::string HostPortPair::ToString() const { | 14 std::string HostPortPair::ToString() const { |
11 return StringPrintf("[Host: %s, Port: %u]", host.c_str(), port); | 15 // Check to see if the host is an IPv6 address. If so, added brackets. |
| 16 if (host.find(':') != std::string::npos) |
| 17 return StringPrintf("[%s]:%u", host.c_str(), port); |
| 18 return StringPrintf("%s:%u", host.c_str(), port); |
12 } | 19 } |
13 | 20 |
14 } // namespace net | 21 } // namespace net |
OLD | NEW |