Skip to content

Commit

Permalink
Clean up and add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
skwijeratne committed Apr 26, 2023
1 parent 0c3bc1f commit 64ad95e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if(CMAKE_BUILD_TYPE MATCHES "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
endif()

option(PISTACHE_BUILD_TESTS "build tests alongside the project" ON)
option(PISTACHE_BUILD_TESTS "build tests alongside the project" OFF)
option(PISTACHE_ENABLE_NETWORK_TESTS "if tests are built, run ones needing network access" ON)
option(PISTACHE_BUILD_EXAMPLES "build examples alongside the project" OFF)
option(PISTACHE_BUILD_DOCS "build docs alongside the project" OFF)
Expand Down
5 changes: 5 additions & 0 deletions include/pistache/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ namespace Uri {
Query(std::initializer_list<std::pair<const std::string, std::string>> params);

void add(std::string name, std::string value);

// Update the parameter value with a new value
void update(std::string& name, std::string value);

Optional<std::string> get(const std::string& name) const;
bool has(const std::string& name) const;
// Return empty string or "?key1=value1&key2=value2" if query exist
Expand Down Expand Up @@ -200,6 +203,8 @@ class Request : public Message {
Method method_;
std::string resource_;
Uri::Query query_;

// The raw parameters received in the request this will keep params with duplicate names also
std::vector<std::pair<std::string,std::string>> raw_params_;

#ifdef LIBSTDCPP_SMARTPTR_LOCK_FIXME
Expand Down
2 changes: 2 additions & 0 deletions src/common/http.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ namespace Private {
if (!request->query_.has(key)) {
request->query_.add(std::move(key), std::move(value));
} else {
// If an existing param, append it to the current value seperated by ','
// so that down stream the values will be converted to std::vector of multiple values.
std::string newValue = request->query_.get(key).get();
newValue += "," + value;
request->query_.update(key, std::move(newValue));
Expand Down

0 comments on commit 64ad95e

Please sign in to comment.