diff --git a/CHANGELOG b/CHANGELOG index b5880568d1..d3fb565db6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,10 @@ -v1.2.beta1 (2013-02-01) +v1.2.beta3 (XXXX-XX-XX) +----------------------- + +* fixed issue #404: keep original request url in request object + + +v1.2.beta2 (2013-02-15) ----------------------- * fixed issue #405: 1.2 compile warnings @@ -43,6 +49,9 @@ v1.2.beta1 (2013-02-01) ArangoDB. Now, error 1203 (Collection not found) is used in AQL too in case a non-existing collection is used. +v1.2.beta1 (2013-02-01) +----------------------- + * fixed issue #382: [Documentation error] Maschine... should be Machine... * unified history file locations for arangod, arangosh, and arangoirb. diff --git a/UnitTests/Philadelphia/string-buffer-test.cpp b/UnitTests/Philadelphia/string-buffer-test.cpp index b3ab8f3a7d..57cdd285df 100644 --- a/UnitTests/Philadelphia/string-buffer-test.cpp +++ b/UnitTests/Philadelphia/string-buffer-test.cpp @@ -530,6 +530,9 @@ BOOST_AUTO_TEST_CASE (tst_timing) { /// @brief tst_doubles //////////////////////////////////////////////////////////////////////////////// +// try to turn off compiler warning for deliberate division by zero +#pragma GCC diagnostic ignored "-Wdiv-by-zero" + BOOST_AUTO_TEST_CASE (tst_doubles) { TRI_string_buffer_t sb; double value; @@ -547,8 +550,9 @@ BOOST_AUTO_TEST_CASE (tst_doubles) { TRI_AppendDoubleStringBuffer(&sb, value); BOOST_CHECK_EQUAL("-inf", sb._buffer); - // div 0 + // div 0. deliberately. value = 1.0 / 0.0; + TRI_ClearStringBuffer(&sb); TRI_AppendDoubleStringBuffer(&sb, value); BOOST_CHECK_EQUAL("inf", sb._buffer); diff --git a/arangod/V8Server/v8-actions.cpp b/arangod/V8Server/v8-actions.cpp index 5438c6aed4..13c88cc155 100644 --- a/arangod/V8Server/v8-actions.cpp +++ b/arangod/V8Server/v8-actions.cpp @@ -321,8 +321,11 @@ static HttpResponse* ExecuteActionVocbase (TRI_vocbase_t* vocbase, req->Set(v8g->UserKey, v8::Null()); } else { - req->Set(v8g->UserKey, v8::String::New(user.c_str())); + req->Set(v8g->UserKey, v8::String::New(user.c_str(), user.size())); } + + string const& fullUrl = request->fullUrl(); + req->Set(v8g->UrlKey, v8::String::New(fullUrl.c_str(), fullUrl.size())); // copy prefix string path = request->prefix(); @@ -337,7 +340,7 @@ static HttpResponse* ExecuteActionVocbase (TRI_vocbase_t* vocbase, char const* sep = ""; for (size_t s = action->_urlParts; s < suffix.size(); ++s) { - suffixArray->Set(index++, v8::String::New(suffix[s].c_str())); + suffixArray->Set(index++, v8::String::New(suffix[s].c_str(), suffix[s].size())); path += sep + suffix[s]; sep = "/"; @@ -730,6 +733,7 @@ void TRI_InitV8Actions (v8::Handle context, ApplicationV8* applicat v8g->ResponseCodeKey = v8::Persistent::New(TRI_V8_SYMBOL("responseCode")); v8g->SuffixKey = v8::Persistent::New(TRI_V8_SYMBOL("suffix")); v8g->TransformationsKey = v8::Persistent::New(TRI_V8_SYMBOL("transformations")); + v8g->UrlKey = v8::Persistent::New(TRI_V8_SYMBOL("url")); v8g->UserKey = v8::Persistent::New(TRI_V8_SYMBOL("user")); v8g->DeleteConstant = v8::Persistent::New(TRI_V8_SYMBOL("DELETE")); diff --git a/lib/Rest/HttpRequest.cpp b/lib/Rest/HttpRequest.cpp index fc93a86897..f7a44ec02a 100644 --- a/lib/Rest/HttpRequest.cpp +++ b/lib/Rest/HttpRequest.cpp @@ -447,22 +447,6 @@ void HttpRequest::setRequestType (HttpRequestType newType) { _type = newType; } -//////////////////////////////////////////////////////////////////////////////// -/// @brief returns whether HTTP version is 1.0 -//////////////////////////////////////////////////////////////////////////////// - -bool HttpRequest::isHttp10 () { - return _version == HTTP_1_0; -} - -//////////////////////////////////////////////////////////////////////////////// -/// @brief returns whether HTTP version is 1.1 -//////////////////////////////////////////////////////////////////////////////// - -bool HttpRequest::isHttp11 () { - return _version == HTTP_1_1; -} - //////////////////////////////////////////////////////////////////////////////// /// @brief returns the authenticated user //////////////////////////////////////////////////////////////////////////////// @@ -685,33 +669,41 @@ void HttpRequest::parseHeader (char* ptr, size_t length) { while (f < valueEnd && *f != '?' && *f != ' ' && *f != '\n') { ++f; } + + pathEnd = f; // no space, question mark or end-of-line if (f == valueEnd) { - pathEnd = f; paramEnd = paramBegin = pathEnd; + + // set full url = complete path + setFullUrl(pathBegin, pathEnd); } // no question mark else if (*f == ' ' || *f == '\n') { - pathEnd = f; *pathEnd = '\0'; paramEnd = paramBegin = pathEnd; + + // set full url = complete path + setFullUrl(pathBegin, pathEnd); } // found a question mark else { - pathEnd = f; - *pathEnd = '\0'; - paramBegin = f + 1; paramEnd = paramBegin; while (paramEnd < valueEnd && *paramEnd != ' ' && *paramEnd != '\n') { ++paramEnd; } + + // set full url = complete path + url parameters + setFullUrl(pathBegin, paramEnd); + // now that the full url was saved, we can insert the null bytes + *pathEnd = '\0'; *paramEnd = '\0'; } @@ -853,6 +845,20 @@ void HttpRequest::parseHeader (char* ptr, size_t length) { } } +//////////////////////////////////////////////////////////////////////////////// +/// @brief sets the full url +/// this will create a copy of the characters in the range, so the original +/// range can be modified afterwards +//////////////////////////////////////////////////////////////////////////////// + +void HttpRequest::setFullUrl (char const* begin, char const* end) { + assert(begin != 0); + assert(end != 0); + assert(begin <= end); + + _fullUrl = string(begin, end - begin); +} + //////////////////////////////////////////////////////////////////////////////// /// @brief sets the path of the request //////////////////////////////////////////////////////////////////////////////// diff --git a/lib/Rest/HttpRequest.h b/lib/Rest/HttpRequest.h index e7c4f51954..0cb054d9d3 100644 --- a/lib/Rest/HttpRequest.h +++ b/lib/Rest/HttpRequest.h @@ -185,6 +185,14 @@ namespace triagens { HttpRequestType requestType () const; +//////////////////////////////////////////////////////////////////////////////// +/// @brief return the full url of the request +//////////////////////////////////////////////////////////////////////////////// + + const string& fullUrl () const { + return _fullUrl; + } + //////////////////////////////////////////////////////////////////////////////// /// @brief sets the http request type //////////////////////////////////////////////////////////////////////////////// @@ -195,13 +203,17 @@ namespace triagens { /// @brief return whether HTTP version is 1.0 //////////////////////////////////////////////////////////////////////////////// - bool isHttp10 (); + bool isHttp10 () const { + return _version == HTTP_1_0; + } //////////////////////////////////////////////////////////////////////////////// /// @brief return whether HTTP version is 1.1 //////////////////////////////////////////////////////////////////////////////// - bool isHttp11 (); + bool isHttp11 () const { + return _version == HTTP_1_1; + } //////////////////////////////////////////////////////////////////////////////// /// @brief returns the full request path @@ -464,6 +476,12 @@ namespace triagens { void parseHeader (char* ptr, size_t length); +//////////////////////////////////////////////////////////////////////////////// +/// @brief sets the full url of the request +//////////////////////////////////////////////////////////////////////////////// + + void setFullUrl (char const* begin, char const* end); + //////////////////////////////////////////////////////////////////////////////// /// @brief sets the path of the request /// @@ -560,6 +578,12 @@ namespace triagens { string _prefix; +//////////////////////////////////////////////////////////////////////////////// +/// @brief the full url requested +//////////////////////////////////////////////////////////////////////////////// + + string _fullUrl; + //////////////////////////////////////////////////////////////////////////////// /// @brief the suffixes for the request path //////////////////////////////////////////////////////////////////////////////// diff --git a/lib/V8/v8-globals.h b/lib/V8/v8-globals.h index 94e41833cd..4420c8f512 100755 --- a/lib/V8/v8-globals.h +++ b/lib/V8/v8-globals.h @@ -97,6 +97,7 @@ typedef struct TRI_v8_global_s { PrefixKey(), ResponseCodeKey(), SuffixKey(), + UrlKey(), UserKey(), WaitForSyncKey(), DocumentIdRegex(), @@ -363,6 +364,12 @@ typedef struct TRI_v8_global_s { v8::Persistent TransformationsKey; +//////////////////////////////////////////////////////////////////////////////// +/// @brief "url" key name +//////////////////////////////////////////////////////////////////////////////// + + v8::Persistent UrlKey; + //////////////////////////////////////////////////////////////////////////////// /// @brief "user" key name ////////////////////////////////////////////////////////////////////////////////