Github user ted-ross commented on a diff in the pull request:
https://github.com/apache/qpid-dispatch/pull/36#discussion_r45614085
--- Diff: src/router_core/management_agent.c ---
@@ -268,6 +269,62 @@ static void qd_core_agent_read_handler(qd_dispatch_t
*qd,
}
+/**
+ * Returns true if all the keys contained in the body map are applicable
to a waypoints, false otherwise
+ * @see qdr_waypoint_columns
+ */
+static bool qd_is_valid_waypoint_keys(qd_parsed_field_t *in_body)
+{
+ if(in_body != 0 && qd_parse_is_map(in_body)) {
+ //
+ // A map containing attributes with invalid values for an entity
MUST result in a failure response with a statusCode of 400 (Bad Request).
+ //
+ int j=0;
+ qd_parsed_field_t *field = qd_parse_sub_key(in_body, j);
+ while (field) {
+ bool found = false;
+ for(int i = 1; i < QDR_WAYPOINT_COLUMN_COUNT; i++) {
+ if (qd_field_iterator_equal(qd_parse_raw(field), (unsigned
char*)qdr_waypoint_columns[i])) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) // Some bad field was specified in the body map.
Reject this request
+ return false;
+ j++;
+ field = qd_parse_sub_key(in_body, j);
+ }
+ }
+ else
+ // The body is either empty or the body is not a map, return false
+ return false;
+
+ return true;
+}
+
+
+/**
+ * The body map containing any attributes that are not applicable for the
entity being updated MUST result in a failure response with a statusCode of 400
(Bad Request).
+ */
+static bool qd_check_body(qd_router_entity_type_t entity_type,
--- End diff --
This function's signature suggests that it is simply checking the message
body. In fact, it also has the side effect of composing the error message for
the response. I think it would be better to stick with the simple check. The
calling logic will then be clearer to understand as it will either go forward
with the request or create an error response based on the outcome of this check.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]