1
0
Fork 0

Merge branch 'devel' of https://github.com/triAGENS/ArangoDB into devel

This commit is contained in:
Heiko Kernbach 2013-02-18 14:44:24 +01:00
commit eda82401e7
6 changed files with 81 additions and 27 deletions

View File

@ -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.

View File

@ -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);

View File

@ -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<v8::Context> context, ApplicationV8* applicat
v8g->ResponseCodeKey = v8::Persistent<v8::String>::New(TRI_V8_SYMBOL("responseCode"));
v8g->SuffixKey = v8::Persistent<v8::String>::New(TRI_V8_SYMBOL("suffix"));
v8g->TransformationsKey = v8::Persistent<v8::String>::New(TRI_V8_SYMBOL("transformations"));
v8g->UrlKey = v8::Persistent<v8::String>::New(TRI_V8_SYMBOL("url"));
v8g->UserKey = v8::Persistent<v8::String>::New(TRI_V8_SYMBOL("user"));
v8g->DeleteConstant = v8::Persistent<v8::String>::New(TRI_V8_SYMBOL("DELETE"));

View File

@ -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
////////////////////////////////////////////////////////////////////////////////

View File

@ -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
////////////////////////////////////////////////////////////////////////////////

View File

@ -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<v8::String> TransformationsKey;
////////////////////////////////////////////////////////////////////////////////
/// @brief "url" key name
////////////////////////////////////////////////////////////////////////////////
v8::Persistent<v8::String> UrlKey;
////////////////////////////////////////////////////////////////////////////////
/// @brief "user" key name
////////////////////////////////////////////////////////////////////////////////