Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: src/gurl.h

Issue 113187: GURL: add a HostNoBrackets() method for bracketless IPv6 literals. (Closed) Base URL: http://google-url.googlecode.com/svn/trunk/
Patch Set: '' Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/gurl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2007, Google Inc. 1 // Copyright 2007, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 // empty if the component is empty or is not present. 235 // empty if the component is empty or is not present.
236 std::string scheme() const { // Not including the colon. See also SchemeIs. 236 std::string scheme() const { // Not including the colon. See also SchemeIs.
237 return ComponentString(parsed_.scheme); 237 return ComponentString(parsed_.scheme);
238 } 238 }
239 std::string username() const { 239 std::string username() const {
240 return ComponentString(parsed_.username); 240 return ComponentString(parsed_.username);
241 } 241 }
242 std::string password() const { 242 std::string password() const {
243 return ComponentString(parsed_.password); 243 return ComponentString(parsed_.password);
244 } 244 }
245 // Note that this may be a hostname, an IPv4 address, or an IPv6 literal
246 // surrounded by square brackets, like "[2001:db8::1]". To exclude these
247 // brackets, use HostNoBrackets() below.
245 std::string host() const { 248 std::string host() const {
246 return ComponentString(parsed_.host); 249 return ComponentString(parsed_.host);
247 } 250 }
248 std::string port() const { // Returns -1 if "default" 251 std::string port() const { // Returns -1 if "default"
249 return ComponentString(parsed_.port); 252 return ComponentString(parsed_.port);
250 } 253 }
251 std::string path() const { // Including first slash following host 254 std::string path() const { // Including first slash following host
252 return ComponentString(parsed_.path); 255 return ComponentString(parsed_.path);
253 } 256 }
254 std::string query() const { // Stuff following '?' 257 std::string query() const { // Stuff following '?'
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 int EffectiveIntPort() const; 303 int EffectiveIntPort() const;
301 304
302 // Extracts the filename portion of the path and returns it. The filename 305 // Extracts the filename portion of the path and returns it. The filename
303 // is everything after the last slash in the path. This may be empty. 306 // is everything after the last slash in the path. This may be empty.
304 std::string ExtractFileName() const; 307 std::string ExtractFileName() const;
305 308
306 // Returns the path that should be sent to the server. This is the path, 309 // Returns the path that should be sent to the server. This is the path,
307 // parameter, and query portions of the URL. It is guaranteed to be ASCII. 310 // parameter, and query portions of the URL. It is guaranteed to be ASCII.
308 std::string PathForRequest() const; 311 std::string PathForRequest() const;
309 312
313 // Returns the host, excluding the square brackets surrounding IPv6 address
314 // literals. This can be useful for passing to getaddrinfo().
315 std::string HostNoBrackets() const;
316
310 // Returns true if this URL's host matches or is in the same domain as 317 // Returns true if this URL's host matches or is in the same domain as
311 // the given input string. For example if this URL was "www.google.com", 318 // the given input string. For example if this URL was "www.google.com",
312 // this would match "com", "google.com", and "www.google.com 319 // this would match "com", "google.com", and "www.google.com
313 // (input domain should be lower-case ASCII to match the canonicalized 320 // (input domain should be lower-case ASCII to match the canonicalized
314 // scheme). This call is more efficient than getting the host and check 321 // scheme). This call is more efficient than getting the host and check
315 // whether host has the specific domain or not because no copies or 322 // whether host has the specific domain or not because no copies or
316 // object constructions are done. 323 // object constructions are done.
317 // 324 //
318 // If function DomainIs has parameter domain_len, which means the parameter 325 // If function DomainIs has parameter domain_len, which means the parameter
319 // lower_ascii_domain does not gurantee to terminate with NULL character. 326 // lower_ascii_domain does not gurantee to terminate with NULL character.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 363
357 // TODO bug 684583: Add encoding for query params. 364 // TODO bug 684583: Add encoding for query params.
358 }; 365 };
359 366
360 // Stream operator so GURL can be used in assertion statements. 367 // Stream operator so GURL can be used in assertion statements.
361 inline std::ostream& operator<<(std::ostream& out, const GURL& url) { 368 inline std::ostream& operator<<(std::ostream& out, const GURL& url) {
362 return out << url.possibly_invalid_spec(); 369 return out << url.possibly_invalid_spec();
363 } 370 }
364 371
365 #endif // GOOGLEURL_SRC_GURL_H__ 372 #endif // GOOGLEURL_SRC_GURL_H__
OLDNEW
« no previous file with comments | « no previous file | src/gurl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698