From bf7ddd5356153de68dc3b2937c30f2ccc8795498 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Tue, 25 Sep 2012 09:41:29 +0200 Subject: [PATCH] added X-Arango headers --- arangod/RestHandler/RestBatchHandler.cpp | 12 ++++++++++-- lib/Rest/HttpResponsePart.cpp | 15 ++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/arangod/RestHandler/RestBatchHandler.cpp b/arangod/RestHandler/RestBatchHandler.cpp index 9d45f4143c..6b92e8b7b4 100644 --- a/arangod/RestHandler/RestBatchHandler.cpp +++ b/arangod/RestHandler/RestBatchHandler.cpp @@ -210,13 +210,21 @@ Handler::status_e RestBatchHandler::execute() { return Handler::HANDLER_FAILED; } + HttpResponsePart* partResponse = dynamic_cast(handler->getResponse()); + if (partResponse == 0) { + delete handler; + generateError(HttpResponse::BAD, TRI_ERROR_INTERNAL, "an error occured during part request processing"); + + return Handler::HANDLER_FAILED; + } + // append the boundary for this subpart _response->body().appendText(boundary + "\r\n"); // append the response header - handler->getResponse()->writeHeader(&_response->body()); + partResponse->writeHeader(&_response->body()); // append the response body - _response->body().appendText(handler->getResponse()->body()); + _response->body().appendText(partResponse->body()); _response->body().appendText("\r\n"); delete handler; diff --git a/lib/Rest/HttpResponsePart.cpp b/lib/Rest/HttpResponsePart.cpp index b1618a0bc5..b819a69a64 100644 --- a/lib/Rest/HttpResponsePart.cpp +++ b/lib/Rest/HttpResponsePart.cpp @@ -79,7 +79,7 @@ HttpResponsePart::~HttpResponsePart () { //////////////////////////////////////////////////////////////////////////////// void HttpResponsePart::writeHeader (StringBuffer* output) { - output->appendText("HTTP/1.1 "); + output->appendText("X-Arango-status: "); output->appendText(responseString(_code)); output->appendText("\r\n"); @@ -108,7 +108,12 @@ void HttpResponsePart::writeHeader (StringBuffer* output) { } char const* value = begin->_value; - + + if (! TRI_EqualString(key, "content-type")) { + // for all headers but content-type, we'll add the prefix "X-Arango-" + output->appendText("X-Arango-"); + } + output->appendText(key); output->appendText(": "); output->appendText(value); @@ -116,16 +121,16 @@ void HttpResponsePart::writeHeader (StringBuffer* output) { } if (seenTransferEncoding && transferEncoding == "chunked") { - output->appendText("transfer-encoding: chunked\r\n\r\n"); + output->appendText("X-Arango-transfer-encoding: chunked\r\n\r\n"); } else { if (seenTransferEncoding) { - output->appendText("transfer-encoding: "); + output->appendText("X-Arango-transfer-encoding: "); output->appendText(transferEncoding); output->appendText("\r\n"); } - output->appendText("content-length: "); + output->appendText("X-Arango-content-length: "); if (_isHeadResponse) { output->appendInteger(_bodySize);