OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef NET_BASE_NET_UTIL_H_ | 5 #ifndef NET_BASE_NET_UTIL_H_ |
6 #define NET_BASE_NET_UTIL_H_ | 6 #define NET_BASE_NET_UTIL_H_ |
7 | 7 |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 | 9 |
10 #if defined(OS_POSIX) | 10 #if defined(OS_POSIX) |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // The rules are: | 110 // The rules are: |
111 // * One or more components separated by '.' | 111 // * One or more components separated by '.' |
112 // * Each component contains only alphanumeric characters and '-' or '_' | 112 // * Each component contains only alphanumeric characters and '-' or '_' |
113 // * The last component begins with an alphanumeric character | 113 // * The last component begins with an alphanumeric character |
114 // * Optional trailing dot after last component (means "treat as FQDN") | 114 // * Optional trailing dot after last component (means "treat as FQDN") |
115 // | 115 // |
116 // NOTE: You should only pass in hosts that have been returned from | 116 // NOTE: You should only pass in hosts that have been returned from |
117 // CanonicalizeHost(), or you may not get accurate results. | 117 // CanonicalizeHost(), or you may not get accurate results. |
118 NET_EXPORT bool IsCanonicalizedHostCompliant(const std::string& host); | 118 NET_EXPORT bool IsCanonicalizedHostCompliant(const std::string& host); |
119 | 119 |
120 // Call these functions to get the html snippet for a directory listing. | |
121 // The return values of both functions are in UTF-8. | |
122 NET_EXPORT std::string GetDirectoryListingHeader(const base::string16& title); | |
123 | |
124 // Given the name of a file in a directory (ftp or local) and | |
125 // other information (is_dir, size, modification time), it returns | |
126 // the html snippet to add the entry for the file to the directory listing. | |
127 // Currently, it's a script tag containing a call to a Javascript function | |
128 // |addRow|. | |
129 // | |
130 // |name| is the file name to be displayed. |raw_bytes| will be used | |
131 // as the actual target of the link (so for example, ftp links should use | |
132 // server's encoding). If |raw_bytes| is an empty string, UTF-8 encoded |name| | |
133 // will be used. | |
134 // | |
135 // Both |name| and |raw_bytes| are escaped internally. | |
136 NET_EXPORT std::string GetDirectoryListingEntry(const base::string16& name, | |
137 const std::string& raw_bytes, | |
138 bool is_dir, | |
139 int64_t size, | |
140 base::Time modified); | |
141 | |
142 // Strip the portions of |url| that aren't core to the network request. | 120 // Strip the portions of |url| that aren't core to the network request. |
143 // - user name / password | 121 // - user name / password |
144 // - reference section | 122 // - reference section |
145 NET_EXPORT GURL SimplifyUrlForRequest(const GURL& url); | 123 NET_EXPORT GURL SimplifyUrlForRequest(const GURL& url); |
146 | 124 |
147 // Resolves a local hostname (such as "localhost" or "localhost6") into | 125 // Resolves a local hostname (such as "localhost" or "localhost6") into |
148 // IP endpoints with the given port. Returns true if |host| is a local | 126 // IP endpoints with the given port. Returns true if |host| is a local |
149 // hostname and false otherwise. Special IPv6 names (e.g. "localhost6") | 127 // hostname and false otherwise. Special IPv6 names (e.g. "localhost6") |
150 // will resolve to an IPv6 address only, whereas other names will | 128 // will resolve to an IPv6 address only, whereas other names will |
151 // resolve to both IPv4 and IPv6. | 129 // resolve to both IPv4 and IPv6. |
152 NET_EXPORT_PRIVATE bool ResolveLocalHostname(base::StringPiece host, | 130 NET_EXPORT_PRIVATE bool ResolveLocalHostname(base::StringPiece host, |
153 uint16_t port, | 131 uint16_t port, |
154 AddressList* address_list); | 132 AddressList* address_list); |
155 | 133 |
156 // Returns true if |host| is one of the local hostnames | 134 // Returns true if |host| is one of the local hostnames |
157 // (e.g. "localhost") or IP addresses (IPv4 127.0.0.0/8 or IPv6 ::1). | 135 // (e.g. "localhost") or IP addresses (IPv4 127.0.0.0/8 or IPv6 ::1). |
158 // | 136 // |
159 // Note that this function does not check for IP addresses other than | 137 // Note that this function does not check for IP addresses other than |
160 // the above, although other IP addresses may point to the local | 138 // the above, although other IP addresses may point to the local |
161 // machine. | 139 // machine. |
162 NET_EXPORT bool IsLocalhost(base::StringPiece host); | 140 NET_EXPORT bool IsLocalhost(base::StringPiece host); |
163 | 141 |
164 // Returns true if the url's host is a Google server. This should only be used | 142 // Returns true if the url's host is a Google server. This should only be used |
165 // for histograms and shouldn't be used to affect behavior. | 143 // for histograms and shouldn't be used to affect behavior. |
166 NET_EXPORT_PRIVATE bool HasGoogleHost(const GURL& url); | 144 NET_EXPORT_PRIVATE bool HasGoogleHost(const GURL& url); |
167 | 145 |
168 } // namespace net | 146 } // namespace net |
169 | 147 |
170 #endif // NET_BASE_NET_UTIL_H_ | 148 #endif // NET_BASE_NET_UTIL_H_ |
OLD | NEW |