20 #ifndef PAGESPEED_KERNEL_HTTP_GOOGLE_URL_H_
21 #define PAGESPEED_KERNEL_HTTP_GOOGLE_URL_H_
30 #include "third_party/chromium/src/googleurl/src/gurl.h"
31 #include "third_party/chromium/src/googleurl/src/url_parse.h"
32 #include "third_party/chromium/src/googleurl/src/url_util.h"
34 namespace net_instaweb {
40 using url_canon::Replacements;
41 using url_parse::PORT_UNSPECIFIED;
42 using url_parse::PORT_INVALID;
43 using url_parse::Component;
44 using url_parse::Parsed;
45 using url_util::Initialize;
46 using url_util::Shutdown;
72 bool Reset(StringPiece new_url);
75 bool Reset(
const GoogleUrl& base, StringPiece relative);
76 bool Reset(
const GoogleUrl& base,
const char* relative);
95 StringPiece unescaped_value)
const;
99 StringPiece escaped_name, StringPiece escaped_value)
const;
150 StringPiece Host()
const;
159 StringPiece
Origin()
const;
164 StringPiece
Query()
const;
167 StringPiece
Scheme()
const;
170 StringPiece
Spec()
const;
177 return gurl_.possibly_invalid_spec().c_str();
180 int IntPort()
const {
return gurl_.IntPort(); }
189 bool is_empty()
const {
return gurl_.is_empty(); }
190 bool has_scheme()
const {
return gurl_.has_scheme(); }
191 bool has_path()
const {
return gurl_.has_path(); }
192 bool has_query()
const {
return gurl_.has_query(); }
194 bool SchemeIs(
const char* lower_ascii_scheme)
const {
195 return gurl_.SchemeIs(lower_ascii_scheme);
200 bool SchemeIs(StringPiece lower_ascii_scheme)
const {
201 return gurl_.SchemeIs(lower_ascii_scheme.as_string().c_str());
217 return gurl_ == other.gurl_;
219 bool operator!=(
const GoogleUrl& other)
const {
220 return gurl_ != other.gurl_;
232 return UnescapeHelper(escaped,
true);
238 return UnescapeHelper(escaped,
false);
262 static const size_t npos;
264 static const char kReservedChars[];
265 static bool IsReservedChar(
char c);
270 static size_t LeafEndPosition(
const GURL& gurl);
271 static size_t LeafStartPosition(
const GURL& gurl);
272 static size_t PathStartPosition(
const GURL& gurl);
273 size_t LeafEndPosition()
const;
274 size_t LeafStartPosition()
const;
275 size_t PathStartPosition()
const;
277 bool convert_plus_to_space);
280 inline bool ResolveHelper(
const GURL& base,
const std::string& path_and_leaf);
284 bool is_web_or_data_valid_;
class GoogleUrl
Definition: google_url.h:58
StringPiece Query() const
bool IsWebOrDataValid() const
Also allows data: URLs.
StringPiece LeafWithQuery() const
static UrlRelativity FindRelativity(StringPiece url)
Find out how relative the URL string is.
//example.com/foo/bar/file.ext?k=v::f
Definition: google_url.h:53
static int DefaultPortForScheme(StringPiece scheme)
StringPiece HostAndPort() const
GoogleUrl * CopyAndAddEscapedQueryParam(StringPiece escaped_name, StringPiece escaped_value) const
bool SchemeIs(StringPiece lower_ascii_scheme) const
Definition: google_url.h:200
bar/file.ext?k=v::f
Definition: google_url.h:55
StringPiece Origin() const
StringPiece PathSansQuery() const
GoogleUrl * CopyAndAddQueryParam(StringPiece unescaped_name, StringPiece unescaped_value) const
StringPiece Spec() const
It is illegal to call this for invalid urls (check IsWebValid() first).
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
static GoogleString EscapeQueryParam(StringPiece unescaped)
StringPiece PathAndLeaf() const
StringPiece Relativize(UrlRelativity url_relativity, const GoogleUrl &base_url) const
StringPiece NetPath() const
StringPiece AllAfterQuery() const
void Clear()
Resets this URL to be invalid.
bool IsWebValid() const
Is a valid web (HTTP or HTTPS) URL. Most users will want this.
/foo/bar/file.ext?k=v::f
Definition: google_url.h:54
StringPiece Scheme() const
Returns scheme of stored url.
StringPiece AllExceptQuery() const
bool operator==(const GoogleUrl &other) const
Defiant equality operator!
Definition: google_url.h:216
StringPiece UncheckedSpec() const
Returns gurl_.spec_ without checking to see if it's valid or empty.
UrlRelativity
namespace url
Definition: google_url.h:51
static GoogleString Sanitize(StringPiece url)
StringPiece AllExceptLeaf() const
static GoogleString UnescapeIgnorePlus(StringPiece escaped)
Definition: google_url.h:237
static GoogleString UnescapeQueryParam(StringPiece escaped)
Definition: google_url.h:231
StringPiece LeafSansQuery() const
StringPiece PathSansLeaf() const
const char * spec_c_str() const
This method is primarily for printf purposes.
Definition: google_url.h:176
int EffectiveIntPort() const
Returns the effective port number, which is dependent on the scheme.
Definition: google_url.h:183
static GoogleString CanonicalizePath(StringPiece path)
GoogleString ExtractFileName() const
http://example.com/foo/bar/file.ext?k=v#f
Definition: google_url.h:52