mirror of
https://github.com/yhirose/cpp-httplib
synced 2024-11-21 14:29:10 -07:00
Fixed decode problem with form-urlencoded data.
This commit is contained in:
parent
62f824e204
commit
cb473e8534
1 changed files with 8 additions and 4 deletions
12
httplib.h
12
httplib.h
|
@ -30,6 +30,9 @@
|
|||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
|
||||
typedef SOCKET socket_t;
|
||||
#else
|
||||
#include <pthread.h>
|
||||
|
@ -579,7 +582,7 @@ inline void parse_query_text(const std::string& s, Map& params)
|
|||
val.assign(b, e);
|
||||
}
|
||||
});
|
||||
params[key] = val;
|
||||
params[key] = detail::decode_url(val);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -742,7 +745,7 @@ inline bool Server::read_request_line(FILE* fp, Request& req)
|
|||
// Parse query text
|
||||
auto len = std::distance(m[3].first, m[3].second);
|
||||
if (len > 0) {
|
||||
detail::parse_query_text(detail::decode_url(m[3]), req.params);
|
||||
detail::parse_query_text(m[3], req.params);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -815,8 +818,9 @@ inline void Server::process_request(FILE* fp_read, FILE* fp_write)
|
|||
if (!detail::read_content(req, fp_read)) {
|
||||
return;
|
||||
}
|
||||
if (req.get_header_value("Content-Type") == "application/x-www-form-urlencoded") {
|
||||
detail::parse_query_text(detail::decode_url(req.body), req.params);
|
||||
static std::string type = "application/x-www-form-urlencoded";
|
||||
if (!req.get_header_value("Content-Type").compare(0, type.size(), type)) {
|
||||
detail::parse_query_text(req.body, req.params);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue