diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-11-26 14:20:17 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-11-26 14:30:11 +0100 |
commit | 108b19f7ef7f9d0bf6c6794bf2be9a12b4cb6400 (patch) | |
tree | b52b1176ec950b5f798c2f6e0f31b86bd832c4ff /src/rest.cpp | |
parent | 8ba38aba42c3b65f1ad61699197566d99d2b761a (diff) | |
parent | 5dc713bfc7bf98c8e1d80fec9c5f5e0417a2bdcd (diff) |
Merge pull request #5326
5dc713b [REST] set REST API behind "-rest" option (Jonas Schnelli)
78bdc81 [REST] give an appropriate response in warmup phase (Jonas Schnelli)
210eba9 [REST] fix headersonly flag for BINARY responses (Jonas Schnelli)
Diffstat (limited to 'src/rest.cpp')
-rw-r--r-- | src/rest.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/rest.cpp b/src/rest.cpp index 122b361719..4953d7e717 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -100,7 +100,7 @@ static bool rest_block(AcceptedConnection *conn, switch (rf) { case RF_BINARY: { string binaryBlock = ssBlock.str(); - conn->stream() << HTTPReply(HTTP_OK, binaryBlock, fRun, true, "application/octet-stream") << binaryBlock << std::flush; + conn->stream() << HTTPReplyHeader(HTTP_OK, fRun, binaryBlock.size(), "application/octet-stream") << binaryBlock << std::flush; return true; } @@ -148,7 +148,7 @@ static bool rest_tx(AcceptedConnection *conn, switch (rf) { case RF_BINARY: { string binaryTx = ssTx.str(); - conn->stream() << HTTPReply(HTTP_OK, binaryTx, fRun, true, "application/octet-stream") << binaryTx << std::flush; + conn->stream() << HTTPReplyHeader(HTTP_OK, fRun, binaryTx.size(), "application/octet-stream") << binaryTx << std::flush; return true; } @@ -188,6 +188,10 @@ bool HTTPReq_REST(AcceptedConnection *conn, bool fRun) { try { + std::string statusmessage; + if(RPCIsInWarmup(&statusmessage)) + throw RESTERR(HTTP_SERVICE_UNAVAILABLE, "Service temporarily unavailable: "+statusmessage); + for (unsigned int i = 0; i < ARRAYLEN(uri_prefixes); i++) { unsigned int plen = strlen(uri_prefixes[i].prefix); if (strURI.substr(0, plen) == uri_prefixes[i].prefix) { |