diff options
| author | Dan Engelbrecht <[email protected]> | 2024-03-26 13:28:07 +0100 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-03-26 13:28:07 +0100 |
| commit | 66cf5342b2fe8bd3f2961dc70b9c302bf4de12bf (patch) | |
| tree | 16dfe666651653f03342dd502e85bbfecd4448c2 /src/zenhttp/httpserver.cpp | |
| parent | remove redundant json11 includes (diff) | |
| download | zen-66cf5342b2fe8bd3f2961dc70b9c302bf4de12bf.tar.xz zen-66cf5342b2fe8bd3f2961dc70b9c302bf4de12bf.zip | |
add filter to projectstore entries request (#25)
* Add HttpServerRequest::Decode to decode http request parameters
* Add support to filter projectstore `entries` request using the `fieldfilter` where the wanted fields are comma (,) delimited
* Add support for responding with compressed payloads for projectstore `entries` requests by adding AcceptType `compressed-binary` to the request header
* Add support for responding with compressed payloads for projectstore `files` requests by adding AcceptType `compressed-binary` to the request header
* Add support for responding with compressed payloads for projectstore `chunkinfo` requests by adding AcceptType `compressed-binary` to the request header
Diffstat (limited to 'src/zenhttp/httpserver.cpp')
| -rw-r--r-- | src/zenhttp/httpserver.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/zenhttp/httpserver.cpp b/src/zenhttp/httpserver.cpp index dcbeac907..adb3128bf 100644 --- a/src/zenhttp/httpserver.cpp +++ b/src/zenhttp/httpserver.cpp @@ -530,6 +530,40 @@ HttpServerRequest::WriteResponse(HttpResponseCode ResponseCode, HttpContentType WriteResponse(ResponseCode, ContentType, Buffers); } +std::string +HttpServerRequest::Decode(std::string_view PercentEncodedString) +{ + size_t Length = PercentEncodedString.length(); + std::string Decoded; + Decoded.reserve(Length); + size_t Offset = 0; + while (Offset < Length) + { + char C = PercentEncodedString[Offset]; + if (C == '%' && (Offset <= (Length - 3))) + { + std::string_view CharHash(&PercentEncodedString[Offset + 1], 2); + uint8_t DecodedChar = 0; + if (ParseHexBytes(CharHash, &DecodedChar)) + { + Decoded.push_back((char)DecodedChar); + Offset += 3; + } + else + { + Decoded.push_back(C); + Offset++; + } + } + else + { + Decoded.push_back(C); + Offset++; + } + } + return Decoded; +} + HttpServerRequest::QueryParams HttpServerRequest::GetQueryParams() { |