1
0
mirror of https://github.com/lammertb/libhttp.git synced 2025-12-22 04:02:04 +03:00

Added URLEncode methods

This commit is contained in:
Thomas Davis
2013-08-31 19:30:05 -04:00
parent 466f3982fe
commit acbe6db15f
5 changed files with 93 additions and 14 deletions

View File

@@ -223,7 +223,7 @@ public:
/**
* urlDecode(const char *, int, std::string &, bool)
* urlDecode(const std::string &, std::string &, bool)
*
* @param src string to be decoded
* @param dst destination string
@@ -237,7 +237,7 @@ public:
}
/**
* urlDecode(const char *, int, std::string &, bool)
* urlDecode(const char *, size_t, std::string &, bool)
*
* @param src buffer to be decoded
* @param src_len length of buffer to be decoded
@@ -249,6 +249,48 @@ public:
*/
static void urlDecode(const char *src, size_t src_len, std::string &dst, bool is_form_url_encoded=true);
/**
* urlDecode(const char *, std::string &, bool)
*
* @param src buffer to be decoded (0 terminated)
* @param dst destination string
* @is_form_url_encoded true if form url encoded
* form-url-encoded data differs from URI encoding in a way that it
* uses '+' as character for space, see RFC 1866 section 8.2.1
* http://ftp.ics.uci.edu/pub/ietf/html/rfc1866.txt
*/
static void urlDecode(const char *src, std::string &dst, bool is_form_url_encoded=true);
/**
* urlEncode(const std::string &, std::string &, bool)
*
* @param src buffer to be encoded
* @param dst destination string
* @append true if string should not be cleared before encoding.
*/
static void urlEncode(const std::string &src, std::string &dst, bool append=false) {
urlEncode(src.c_str(), src.length(), dst, append);
}
/**
* urlEncode(const char *, size_t, std::string &, bool)
*
* @param src buffer to be encoded (0 terminated)
* @param dst destination string
* @append true if string should not be cleared before encoding.
*/
static void urlEncode(const char *src, std::string &dst, bool append=false);
/**
* urlEncode(const char *, size_t, std::string &, bool)
*
* @param src buffer to be encoded
* @param src_len length of buffer to be decoded
* @param dst destination string
* @append true if string should not be cleared before encoding.
*/
static void urlEncode(const char *src, size_t src_len, std::string &dst, bool append=false);
protected:
/**

View File

@@ -409,6 +409,11 @@ const char *mg_version(void);
int mg_url_decode(const char *src, int src_len, char *dst,
int dst_len, int is_form_url_encoded);
// URL-encode input buffer into destination buffer.
// returns the length of the resulting buffer or -1
// is the buffer is too small.
int mg_url_encode(const char *src, char *dst, size_t dst_len);
// MD5 hash given strings.
// Buffer 'buf' must be 33 bytes long. Varargs is a NULL terminated list of
// ASCIIz strings. When function returns, buf will contain human-readable