Commit 9663837d authored by Ian Roddis's avatar Ian Roddis

Adding configure-time payload parameter, and some documentation

parent 91ed6916
...@@ -6,6 +6,12 @@ option(PISTACHE_BUILD_TESTS "build tests alongside the project" OFF) ...@@ -6,6 +6,12 @@ option(PISTACHE_BUILD_TESTS "build tests alongside the project" OFF)
option(PISTACHE_BUILD_EXAMPLES "build examples alongside the project" OFF) option(PISTACHE_BUILD_EXAMPLES "build examples alongside the project" OFF)
option(PISTACHE_INSTALL "add pistache as install target (recommended)" ON) option(PISTACHE_INSTALL "add pistache as install target (recommended)" ON)
# Allow redefining the max payload size
if (NOT PISTACHE_MAX_PAYLOAD)
set(PISTACHE_MAX_PAYLOAD 4096)
endif()
add_definitions( -DMAX_PAYLOAD=${PISTACHE_MAX_PAYLOAD} )
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11) if(COMPILER_SUPPORTS_CXX11)
......
...@@ -52,6 +52,14 @@ Be patient, async_test can take some time before completing. ...@@ -52,6 +52,14 @@ Be patient, async_test can take some time before completing.
And that's it, now you can start playing with your newly installed Pistache framework. And that's it, now you can start playing with your newly installed Pistache framework.
Some other CMAKE defines:
| Option | Default | Description |
|---------------------------|-------------|-------------------------------------------------------------|
| PISTACHE_BUILD_EXAMPLES | False | Build all of the example apps |
| PISTACHE_BUILD_TESTS | False | Build all of the unit tests |
| PISTACHE_MAX_PAYLOAD | 4096 | Maximum size of requests, in bytes (including HTTP headers) |
# Example # Example
## Hello World (server) ## Hello World (server)
......
...@@ -52,13 +52,20 @@ ...@@ -52,13 +52,20 @@
// Until we require C++17 compiler with [[maybe_unused]] // Until we require C++17 compiler with [[maybe_unused]]
#define UNUSED(x) (void)(x); #define UNUSED(x) (void)(x);
#ifndef MAX_PAYLOAD
#define MAX_PAYLOAD 4096
#endif
// Allow compile-time overload
namespace Pistache { namespace Pistache {
namespace Const { namespace Const {
static constexpr int MaxBacklog = 128; static constexpr size_t MaxBacklog = 128;
static constexpr int MaxEvents = 1024; static constexpr size_t MaxEvents = 1024;
static constexpr int MaxBuffer = 4096; static constexpr size_t MaxBuffer = 4096;
static constexpr int MaxPayload = 1073741824;
static constexpr int ChunkSize = 1024; // Defined from CMakeLists.txt in project root
static constexpr size_t MaxPayload = MAX_PAYLOAD;
static constexpr size_t ChunkSize = 1024;
} // namespace Const } // namespace Const
} // namespace Pistache } // namespace Pistache
...@@ -97,13 +97,9 @@ public: ...@@ -97,13 +97,9 @@ public:
bool feed(const char* data, size_t len) { bool feed(const char* data, size_t len) {
if (bytes.size() + len > MAX_SIZE) { return false; } if (bytes.size() + len > MAX_SIZE) { return false; }
// get current offset // persist current offset
size_t readOffset = static_cast<size_t>(this->gptr() - this->eback()); size_t readOffset = static_cast<size_t>(this->gptr() - this->eback());
std::copy(data, data + len, std::back_inserter(bytes)); std::copy(data, data + len, std::back_inserter(bytes));
if (readOffset == 0) {
readOffset = bytes.size() - len;
}
Base::setg(bytes.data() Base::setg(bytes.data()
, bytes.data() + readOffset , bytes.data() + readOffset
, bytes.data() + bytes.size()); , bytes.data() + bytes.size());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment