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_WIN) | 10 #if defined(OS_WIN) |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 // Returns either the host from |url|, or, if the host is empty, the full spec. | 167 // Returns either the host from |url|, or, if the host is empty, the full spec. |
168 NET_EXPORT std::string GetHostOrSpecFromURL(const GURL& url); | 168 NET_EXPORT std::string GetHostOrSpecFromURL(const GURL& url); |
169 | 169 |
170 // Return the value of the HTTP response header with name 'name'. 'headers' | 170 // Return the value of the HTTP response header with name 'name'. 'headers' |
171 // should be in the format that URLRequest::GetResponseHeaders() returns. | 171 // should be in the format that URLRequest::GetResponseHeaders() returns. |
172 // Returns the empty string if the header is not found. | 172 // Returns the empty string if the header is not found. |
173 NET_EXPORT std::string GetSpecificHeader(const std::string& headers, | 173 NET_EXPORT std::string GetSpecificHeader(const std::string& headers, |
174 const std::string& name); | 174 const std::string& name); |
175 | 175 |
176 // TODO(abarth): Move these functions to http_content_disposition.cc. | |
177 bool DecodeFilenameValue(const std::string& input, | |
178 const std::string& referrer_charset, | |
179 std::string* output); | |
180 bool DecodeExtValue(const std::string& value, std::string* output); | |
181 | |
182 // Converts the given host name to unicode characters. This can be called for | 176 // Converts the given host name to unicode characters. This can be called for |
183 // any host name, if the input is not IDN or is invalid in some way, we'll just | 177 // any host name, if the input is not IDN or is invalid in some way, we'll just |
184 // return the ASCII source so it is still usable. | 178 // return the ASCII source so it is still usable. |
185 // | 179 // |
186 // The input should be the canonicalized ASCII host name from GURL. This | 180 // The input should be the canonicalized ASCII host name from GURL. This |
187 // function does NOT accept UTF-8! | 181 // function does NOT accept UTF-8! |
188 // | 182 // |
189 // |languages| is a comma separated list of ISO 639 language codes. It | 183 // |languages| is a comma separated list of ISO 639 language codes. It |
190 // is used to determine whether a hostname is 'comprehensible' to a user | 184 // is used to determine whether a hostname is 'comprehensible' to a user |
191 // who understands languages listed. |host| will be converted to a | 185 // who understands languages listed. |host| will be converted to a |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 // If text starts with "www." it is removed, otherwise text is returned | 239 // If text starts with "www." it is removed, otherwise text is returned |
246 // unmodified. | 240 // unmodified. |
247 NET_EXPORT string16 StripWWW(const string16& text); | 241 NET_EXPORT string16 StripWWW(const string16& text); |
248 | 242 |
249 // Runs |url|'s host through StripWWW(). |url| must be valid. | 243 // Runs |url|'s host through StripWWW(). |url| must be valid. |
250 NET_EXPORT string16 StripWWWFromHost(const GURL& url); | 244 NET_EXPORT string16 StripWWWFromHost(const GURL& url); |
251 | 245 |
252 // Generates a filename using the first successful method from the following (in | 246 // Generates a filename using the first successful method from the following (in |
253 // order): | 247 // order): |
254 // | 248 // |
255 // 1) The raw Content-Disposition header in |content_disposition| (as read from | 249 // 1) The raw Content-Disposition header in |content_disposition| as read from |
256 // the network. |referrer_charset| is used as described in the comment for | 250 // the network. |referrer_charset| is used to decode non-ASCII strings. |
257 // GetFileNameFromCD(). | |
258 // 2) |suggested_name| if specified. |suggested_name| is assumed to be in | 251 // 2) |suggested_name| if specified. |suggested_name| is assumed to be in |
259 // UTF-8. | 252 // UTF-8. |
260 // 3) The filename extracted from the |url|. |referrer_charset| will be used to | 253 // 3) The filename extracted from the |url|. |referrer_charset| will be used to |
261 // interpret the URL if there are non-ascii characters. | 254 // interpret the URL if there are non-ascii characters. |
262 // 4) |default_name|. If non-empty, |default_name| is assumed to be a filename | 255 // 4) |default_name|. If non-empty, |default_name| is assumed to be a filename |
263 // and shouldn't contain a path. |default_name| is not subject to validation | 256 // and shouldn't contain a path. |default_name| is not subject to validation |
264 // or sanitization, and therefore shouldn't be a user supplied string. | 257 // or sanitization, and therefore shouldn't be a user supplied string. |
265 // 5) The hostname portion from the |url| | 258 // 5) The hostname portion from the |url| |
266 // | 259 // |
267 // Then, leading and trailing '.'s will be removed. On Windows, trailing spaces | 260 // Then, leading and trailing '.'s will be removed. On Windows, trailing spaces |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 | 511 |
519 // Returns list of network interfaces except loopback interface. If an | 512 // Returns list of network interfaces except loopback interface. If an |
520 // interface has more than one address, a separate entry is added to | 513 // interface has more than one address, a separate entry is added to |
521 // the list for each address. | 514 // the list for each address. |
522 // Can be called only on a thread that allows IO. | 515 // Can be called only on a thread that allows IO. |
523 NET_EXPORT bool GetNetworkList(NetworkInterfaceList* networks); | 516 NET_EXPORT bool GetNetworkList(NetworkInterfaceList* networks); |
524 | 517 |
525 } // namespace net | 518 } // namespace net |
526 | 519 |
527 #endif // NET_BASE_NET_UTIL_H_ | 520 #endif // NET_BASE_NET_UTIL_H_ |
OLD | NEW |