Fix context returned in JSON error (had null bytes).
Update status test cases to match new API.
This commit is contained in:
parent
89d56e1cd1
commit
2cf19010e3
@ -39,29 +39,29 @@ Feature: Status messages
|
|||||||
Given the node locations
|
Given the node locations
|
||||||
| node | lat | lon |
|
| node | lat | lon |
|
||||||
| a | 1.00 | 1.00 |
|
| a | 1.00 | 1.00 |
|
||||||
| b | 1.01 | 1.00 |
|
| b | 2.00 | 1.00 |
|
||||||
|
|
||||||
And the ways
|
And the ways
|
||||||
| nodes |
|
| nodes |
|
||||||
| ab |
|
| ab |
|
||||||
|
|
||||||
When I route I should get
|
When I route I should get
|
||||||
| request | status | message |
|
| request | status | message |
|
||||||
| viaroute?loc=1,1&loc=1.01,1 | 200 | |
|
| route/v1/driving/1,1;1,2 | 200 | |
|
||||||
| nonsense | 400 | Service not found |
|
| nonsense | 400 | URL string malformed close to position 0: "/no" |
|
||||||
| nonsense?loc=1,1&loc=1.01,1 | 400 | Service not found |
|
| nonsense/v1/driving/1,1;1,2 | 400 | Service nonsense not found! |
|
||||||
| | 400 | Query string malformed close to position 0 |
|
| | 400 | URL string malformed close to position 0: "/" |
|
||||||
| / | 400 | Query string malformed close to position 0 |
|
| / | 400 | URL string malformed close to position 0: "//" |
|
||||||
| ? | 400 | Query string malformed close to position 0 |
|
| ? | 400 | URL string malformed close to position 0: "/?" |
|
||||||
| viaroute?loc= | 400 | Query string malformed close to position 9 |
|
| route/v1/driving | 400 | URL string malformed close to position 0: "/ro" |
|
||||||
| viaroute?loc=1 | 400 | Query string malformed close to position 9 |
|
| route/v1/driving/ | 400 | URL string malformed close to position 0: "/ro" |
|
||||||
| viaroute?loc=1,1 | 400 | Invalid coordinates |
|
| route/v1/driving/1 | 400 | Query string malformed close to position 0 |
|
||||||
| viaroute?loc=1,1,1 | 400 | Query string malformed close to position 17 |
|
| route/v1/driving/1,1 | 400 | Number of coordinates needs to be at least two. |
|
||||||
| viaroute?loc=x | 400 | Query string malformed close to position 9 |
|
| route/v1/driving/1,1,1 | 400 | Query string malformed close to position 3 |
|
||||||
| viaroute?loc=x,y | 400 | Query string malformed close to position 9 |
|
| route/v1/driving/x | 400 | Query string malformed close to position 0 |
|
||||||
| viaroute?loc=1,1&loc= | 400 | Query string malformed close to position 17 |
|
| route/v1/driving/x,y | 400 | Query string malformed close to position 0 |
|
||||||
| viaroute?loc=1,1&loc=1 | 400 | Query string malformed close to position 17 |
|
| route/v1/driving/1,1; | 400 | Query string malformed close to position 3 |
|
||||||
| viaroute?loc=1,1&loc=1,1 | 200 | |
|
| route/v1/driving/1,1;1 | 400 | Query string malformed close to position 3 |
|
||||||
| viaroute?loc=1,1&loc=1,1,1 | 400 | Query string malformed close to position 25 |
|
| route/v1/driving/1,1;1,1,1 | 400 | Query string malformed close to position 7 |
|
||||||
| viaroute?loc=1,1&loc=x | 400 | Query string malformed close to position 17 |
|
| route/v1/driving/1,1;x | 400 | Query string malformed close to position 3 |
|
||||||
| viaroute?loc=1,1&loc=x,y | 400 | Query string malformed close to position 17 |
|
| route/v1/driving/1,1;x,y | 400 | Query string malformed close to position 3 |
|
||||||
|
@ -99,9 +99,12 @@ void RequestHandler::HandleRequest(const http::request ¤t_request, http::r
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
const auto position = std::distance(request_string.begin(), api_iterator);
|
const auto position = std::distance(request_string.begin(), api_iterator);
|
||||||
const auto context_begin = request_string.begin() + std::max(position - 3UL, 0UL);
|
BOOST_ASSERT(position >= 0);
|
||||||
|
const auto context_begin = request_string.begin() + ((position < 3) ? 0 : (position - 3UL));
|
||||||
|
BOOST_ASSERT(context_begin >= request_string.begin());
|
||||||
const auto context_end =
|
const auto context_end =
|
||||||
request_string.begin() + std::min(position + 3UL, request_string.size());
|
request_string.begin() + std::min(position + 3UL, request_string.size());
|
||||||
|
BOOST_ASSERT(context_end <= request_string.end());
|
||||||
std::string context(context_begin, context_end);
|
std::string context(context_begin, context_end);
|
||||||
|
|
||||||
current_reply.status = http::reply::bad_request;
|
current_reply.status = http::reply::bad_request;
|
||||||
|
Loading…
Reference in New Issue
Block a user