From e5721f6b4dd7e4084a14b6f2f38bfb3672796ac9 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sun, 12 Jan 2025 10:25:56 -0800 Subject: http: server error handling improvements and tests We want to consume the request properly on an error, so that we can give a reasonable response. We were prematurely closing the connection for certain failure modes. We still have to fix overly long URIs and headers, but thats next! --- src/testing/nuts.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/testing/nuts.h') diff --git a/src/testing/nuts.h b/src/testing/nuts.h index ac502ff8..290af723 100644 --- a/src/testing/nuts.h +++ b/src/testing/nuts.h @@ -214,7 +214,7 @@ extern const char *nuts_ecdsa_client_crt; nng_strerror(result_), result_); \ } while (0) -// NUTS_ERROR tests for a specific NNG error code. +// NUTS_FAIL tests for a specific NNG error code. #define NUTS_FAIL(cond, expect) \ do { \ int result_ = (cond); \ @@ -325,4 +325,12 @@ extern const char *nuts_ecdsa_client_crt; }; #endif +#define NUTS_HTTP_STATUS(conn, expect) \ + do { \ + TEST_CHECK(nng_http_get_status(conn) == (expect)); \ + TEST_MSG("HTTP status: expected %d (%s) got %d (%s)", expect, \ + #expect, nng_http_get_status(conn), \ + nng_http_get_reason(conn)); \ + } while (0) + #endif // NNG_TEST_NUTS_H -- cgit v1.2.3-70-g09d2