lishuxu commented on code in PR #1132:
URL: https://github.com/apache/iceberg-cpp/pull/1132#discussion_r4720354615
##########
src/iceberg/test/http_client_test.cc:
##########
@@ -249,8 +263,273 @@ void ServeOnce(int listener, std::string_view response,
bool end) {
::close(connection);
}
+HttpHeaders RequestHeaders(const std::string& request) {
+ HttpHeaders headers;
+ const auto header_end = request.find("\r\n\r\n");
+ if (header_end == std::string::npos) return headers;
+ auto start = request.find("\r\n") + 2;
+ while (start < header_end) {
+ auto end = request.find("\r\n", start);
+ auto separator = request.find(':', start);
+ if (separator < end) {
+ auto value_start = request.find_first_not_of(" \t", separator + 1);
+ headers.emplace(request.substr(start, separator - start),
+ request.substr(value_start, end - value_start));
+ }
+ start = end + 2;
+ }
+ return headers;
+}
+
+std::unordered_map<std::string, std::string> RequestForm(const std::string&
request) {
+ std::unordered_map<std::string, std::string> form;
+ auto header_end = request.find("\r\n\r\n");
+ if (header_end == std::string::npos) return form;
+ auto body = request.substr(header_end + 4);
+ size_t start = 0;
+ while (start < body.size()) {
+ auto end = body.find('&', start);
+ auto field = body.substr(start, end == std::string::npos ? end : end -
start);
+ auto separator = field.find('=');
+ if (separator != std::string::npos) {
+ form.emplace(UrlEncoder::Decode(field.substr(0, separator)),
+ UrlEncoder::Decode(field.substr(separator + 1)));
Review Comment:
The parser now converts raw + to a space before percent-decoding. This
exposed an encoding bug in PostForm(), so I fixed it and added a round-trip
test with catalog reports+read.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]