38 #include "NptStrings.h" 44 const NPT_UInt16 NPT_URL_INVALID_PORT = 0;
45 const NPT_UInt16 NPT_URL_DEFAULT_HTTP_PORT = 80;
46 const NPT_UInt16 NPT_URL_DEFAULT_HTTPS_PORT = 443;
61 static const char*
const PathCharsToEncode;
62 static const char*
const QueryCharsToEncode;
63 static const char*
const FragmentCharsToEncode;
64 static const char*
const UnsafeCharsToEncode;
67 static NPT_String PercentEncode(
const char* str,
const char* chars,
bool encode_percents=
true);
68 static NPT_String PercentDecode(
const char* str);
69 static SchemeId ParseScheme(
const NPT_String& scheme);
72 NPT_Uri() : m_SchemeId(SCHEME_ID_UNKNOWN) {}
77 void SetScheme(
const char* scheme);
78 NPT_Result SetSchemeFromUri(
const char* uri);
79 SchemeId GetSchemeId()
const {
96 static NPT_String UrlEncode(
const char* str,
bool encode_percents=
true);
101 Field(
const char* name,
const char* value,
bool encoded);
114 NPT_Result Parse(
const char* query);
115 NPT_Result SetField(
const char* name,
const char* value,
bool encoded=
false);
116 NPT_Result AddField(
const char* name,
const char* value,
bool encoded=
false);
117 const char* GetField(
const char* name);
145 NPT_Url(
const char* url, NPT_UInt16 default_port = 0);
163 const char* query = NULL,
164 const char* fragment = NULL);
172 NPT_Result Parse(
const char* url, NPT_UInt16 default_port = 0);
179 NPT_Result ParsePathPlus(
const char* path_plus);
217 virtual bool IsValid()
const;
243 NPT_Result SetHost(
const char* host);
250 NPT_Result SetPort(NPT_UInt16 port);
260 NPT_Result SetPath(
const char* path,
bool encoded=
false);
270 NPT_Result SetQuery(
const char* query,
bool encoded=
false);
280 NPT_Result SetFragment(
const char* fragment,
bool encoded=
false);
289 virtual NPT_String ToRequestString(
bool with_fragment =
false)
const;
300 virtual NPT_String ToStringWithDefaultPort(NPT_UInt16 default_port,
bool with_fragment =
true)
const;
308 virtual NPT_String ToString(
bool with_fragment =
true)
const;
313 bool m_HostIsIpv6Address;
322 #endif // _NPT_URI_H_ const NPT_String & GetHost() const
Returns the host part of the URL, in its encoded form.
Definition: NptUri.h:184
bool HasQuery() const
Returns whether the URL has a query part or not.
Definition: NptUri.h:229
NPT_UInt16 GetPort() const
Returns the port number of the URL.
Definition: NptUri.h:189
bool HasFragment() const
Returns whether the URL has a fragment part or not.
Definition: NptUri.h:236
NPT_String GetPath(bool decoded) const
Returns the path part of the URL, in its encoded or decoded form.
Definition: NptUri.h:199
const NPT_String & GetQuery() const
Returns the query part of the URL, in its encoded form.
Definition: NptUri.h:204
Definition: NptStrings.h:57
const NPT_String & GetPath() const
Returns the path part of the URL, in its encoded form.
Definition: NptUri.h:194
const NPT_String & GetFragment() const
Returns the fragment part of the URL, in its encoded form.
Definition: NptUri.h:209