diff --git a/Documentation/Books/Manual/Appendix/Deprecated/Actions/JsonExample.md b/Documentation/Books/Manual/Appendix/Deprecated/Actions/JsonExample.md index 0a4ac6b391..d4a5bc4ced 100644 --- a/Documentation/Books/Manual/Appendix/Deprecated/Actions/JsonExample.md +++ b/Documentation/Books/Manual/Appendix/Deprecated/Actions/JsonExample.md @@ -136,7 +136,7 @@ You should see something like @startDocuBlockInline JSON_07_fetchroutingCreateHelloEcho @EXAMPLE_ARANGOSH_OUTPUT{JSON_07_fetchroutingCreateHelloEcho} - arango.GET("/hello/echo") + arango.GET_RAW("/hello/echo", { "accept" : "application/json" }) @END_EXAMPLE_ARANGOSH_OUTPUT @endDocuBlock JSON_07_fetchroutingCreateHelloEcho @@ -199,7 +199,7 @@ Reload the routing and check http:// 127.0.0.1:8529/hello/echo: @startDocuBlockInline JSON_10_fetchroutingCreateEchoController @EXAMPLE_ARANGOSH_OUTPUT{JSON_10_fetchroutingCreateEchoController} - arango.GET("/hello/echo") + arango.GET_RAW("/hello/echo", { "accept" : "application/json" }) @END_EXAMPLE_ARANGOSH_OUTPUT @endDocuBlock JSON_10_fetchroutingCreateEchoController @@ -271,7 +271,7 @@ You can also store a function directly in the routing table. @startDocuBlockInline JSON_12b_fetchroutingEchoFunction @EXAMPLE_ARANGOSH_OUTPUT{JSON_12b_fetchroutingEchoFunction} - arango.GET("hello/echo") + arango.GET_RAW("hello/echo", { "accept" : "application/json" }) db._query("FOR route IN _routing FILTER route.url == '/hello/echo' REMOVE route in _routing") require("internal").reloadRouting() @END_EXAMPLE_ARANGOSH_OUTPUT @@ -317,7 +317,7 @@ You should see something like @startDocuBlockInline JSON_14_fetchroutingRequestHelloEcho @EXAMPLE_ARANGOSH_OUTPUT{JSON_14_fetchroutingRequestHelloEcho} - arango.GET("/hello/echo") + arango.GET_RAW("/hello/echo", { "accept" : "application/json" }) db._query("FOR route IN _routing FILTER route.url == '/hello/echo' REMOVE route in _routing") require("internal").reloadRouting() @END_EXAMPLE_ARANGOSH_OUTPUT @@ -344,7 +344,7 @@ You now see the options in the result: @startDocuBlockInline JSON_16_fetchroutingEchoRequestOptions @EXAMPLE_ARANGOSH_OUTPUT{JSON_16_fetchroutingEchoRequestOptions} - arango.GET("/echo") + arango.GET_RAW("/echo", { accept: "application/json" }) db._query("FOR route IN _routing FILTER route.url == '/echo' REMOVE route in _routing") require("internal").reloadRouting() @END_EXAMPLE_ARANGOSH_OUTPUT diff --git a/Documentation/DocuBlocks/Rest/AQL/delete_api_aqlfunction.md b/Documentation/DocuBlocks/Rest/AQL/delete_api_aqlfunction.md index 102f8a9b02..0ab5a4e844 100644 --- a/Documentation/DocuBlocks/Rest/AQL/delete_api_aqlfunction.md +++ b/Documentation/DocuBlocks/Rest/AQL/delete_api_aqlfunction.md @@ -82,7 +82,7 @@ deletes a function: code : "function (x) { return x*x; }" }; - db._connection.POST("/_api/aqlfunction", JSON.stringify(body)); + db._connection.POST("/_api/aqlfunction", body); var response = logCurlRequest('DELETE', url); assert(response.code === 200); diff --git a/Documentation/Scripts/exampleHeader.js b/Documentation/Scripts/exampleHeader.js index 71d1ba23b9..8f49e1dd2b 100644 --- a/Documentation/Scripts/exampleHeader.js +++ b/Documentation/Scripts/exampleHeader.js @@ -107,7 +107,7 @@ const log = function (a) { appender(internal.stopCaptureMode()); }; -var logCurlRequestRaw = internal.appendCurlRequest(shellAppender,jsonAppender, rawAppender); +var logCurlRequestRaw = internal.appendCurlRequest(shellAppender, jsonAppender, rawAppender); var logCurlRequest = function () { if ((arguments.length > 1) && (arguments[1] !== undefined) && @@ -172,28 +172,25 @@ var runTestLine = function(line, testName, sourceFN, sourceLine, lineCount, show /* jshint ignore:start */ if (!showCmd || isLoop) { eval(line); - } - else { + } else { eval("XXX = " + line); } /* jshint ignore:end */ if (expectError !== undefined) { - throw new Error("expected to throw with " + expectError + " but didn't!"); + throw new Error("expected to throw with " + expectError + " but didn't!"); } } catch (err) { if (expectError !== undefined) { if (err.errorNum === errors[expectError].code) { print(err); - } - else { + } else { print(err); createErrorMessage(err, line, testName, sourceFN, sourceLine, lineCount, " caught unexpected exception!"); } - } - else { - createErrorMessage(err, line, testName, sourceFN, sourceLine, lineCount, " caught an exception!\n"); - print(err); + } else { + createErrorMessage(err, line, testName, sourceFN, sourceLine, lineCount, " caught an exception!\n"); + print(err); } } if (showCmd && XXX !== undefined) { @@ -258,12 +255,12 @@ var addIgnoreCollection = function(collectionName) { var removeIgnoreCollection = function(collectionName) { // print("from now on checking again whether this collection dropped: " + collectionName); - for (j=0; j < collectionAlreadyThere.length; j++) { + for (j = 0; j < collectionAlreadyThere.length; j++) { if (collectionAlreadyThere[j] === collectionName) { collectionAlreadyThere[j] = undefined; } } - for (j=0; j < ignoreCollectionAlreadyThere.length; j++) { + for (j = 0; j < ignoreCollectionAlreadyThere.length; j++) { if (ignoreCollectionAlreadyThere[j] === collectionName) { ignoreCollectionAlreadyThere[j] = undefined; } diff --git a/arangod/Aql/Ast.cpp b/arangod/Aql/Ast.cpp index 26b14fae1c..c3858f00c2 100644 --- a/arangod/Aql/Ast.cpp +++ b/arangod/Aql/Ast.cpp @@ -1649,6 +1649,9 @@ void Ast::injectBindParameters( TRI_ASSERT(graphNode->isStringValue()); std::string graphName = graphNode->getString(); auto graph = _query->lookupGraphByName(graphName); + if (graph == nullptr) { + THROW_ARANGO_EXCEPTION(TRI_ERROR_GRAPH_NOT_FOUND); + } TRI_ASSERT(graph != nullptr); auto vColls = graph->vertexCollections(); @@ -1686,6 +1689,9 @@ void Ast::injectBindParameters( TRI_ASSERT(graphNode->isStringValue()); std::string graphName = graphNode->getString(); auto graph = _query->lookupGraphByName(graphName); + if (graph == nullptr) { + THROW_ARANGO_EXCEPTION(TRI_ERROR_GRAPH_NOT_FOUND); + } TRI_ASSERT(graph != nullptr); auto vColls = graph->vertexCollections(); diff --git a/js/client/bootstrap/modules/internal.js b/js/client/bootstrap/modules/internal.js index 182a10f52d..863339fb30 100644 --- a/js/client/bootstrap/modules/internal.js +++ b/js/client/bootstrap/modules/internal.js @@ -158,13 +158,18 @@ let appendHeaders = function(appender, headers) { return function (method, url, body, headers) { var response; var curl; - var i; var jsonBody = false; if ((typeof body !== 'string') && (body !== undefined)) { jsonBody = true; body = exports.inspect(body); } + if (headers === undefined || headers === null || headers === '') { + headers = {}; + } + if (!headers.hasOwnProperty('Accept') && !headers.hasOwnProperty('accept')) { + headers['accept'] = 'application/json'; + } curl = 'shell> curl '; @@ -185,12 +190,12 @@ let appendHeaders = function(appender, headers) { } else if (method === 'HEAD') { response = exports.arango.HEAD_RAW(url, headers); curl += '-X ' + method + ' '; - } else if (method === 'OPTION') { + } else if (method === 'OPTION' || method === 'OPTIONS') { response = exports.arango.OPTION_RAW(url, body, headers); curl += '-X ' + method + ' '; } if (headers !== undefined && headers !== '') { - for (i in headers) { + for (let i in headers) { if (headers.hasOwnProperty(i)) { curl += "--header '" + i + ': ' + headers[i] + "' "; }