aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/test_http_reasons.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/microhttpd/test_http_reasons.c')
-rw-r--r--src/microhttpd/test_http_reasons.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/microhttpd/test_http_reasons.c b/src/microhttpd/test_http_reasons.c
index 7c2c3efd..b648c3b0 100644
--- a/src/microhttpd/test_http_reasons.c
+++ b/src/microhttpd/test_http_reasons.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of libmicrohttpd 2 This file is part of libmicrohttpd
3 Copyright (C) 2017 Karlson2k (Evgeny Grin) 3 Copyright (C) 2017-2021 Karlson2k (Evgeny Grin)
4 4
5 This test tool is free software; you can redistribute it and/or 5 This test tool is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License as 6 modify it under the terms of the GNU General Public License as
@@ -25,18 +25,36 @@
25 25
26#include "mhd_options.h" 26#include "mhd_options.h"
27#include <stdio.h> 27#include <stdio.h>
28#include <string.h>
28#include "microhttpd.h" 29#include "microhttpd.h"
29#include "mhd_str.h" 30#include "mhd_str.h"
30 31
32static const char *const r_unknown = "unknown";
33
31static int 34static int
32expect_result (int code, const char*expected) 35expect_result (int code, const char *expected)
33{ 36{
34 const char*const reason = MHD_get_reason_phrase_for (code); 37 const char *const reason = MHD_get_reason_phrase_for (code);
35 if (MHD_str_equal_caseless_ (reason, expected)) 38 const size_t len = MHD_get_reason_phrase_len_for (code);
39 size_t exp_len;
40 if (! MHD_str_equal_caseless_ (reason, expected))
41 {
42 fprintf (stderr,
43 "Incorrect reason returned for code %d:\n Returned: \"%s\" \tExpected: \"%s\"\n",
44 code, reason, expected);
45 return 0;
46 }
47 if (r_unknown == expected)
48 exp_len = 0;
49 else
50 exp_len = strlen (expected);
51 if (exp_len != len)
52 {
53 fprintf (stderr,
54 "Incorrect reason length returned for code %d:\n Returned: \"%u\" \tExpected: \"%u\"\n",
55 code, (unsigned) len, (unsigned) exp_len);
36 return 0; 56 return 0;
37 fprintf (stderr, 57 }
38 "Incorrect reason returned for code %d:\n Returned: \"%s\" \tExpected: \"%s\"\n",
39 code, reason, expected);
40 return 1; 58 return 1;
41} 59}
42 60
@@ -44,7 +62,7 @@ expect_result (int code, const char*expected)
44static int 62static int
45expect_absent (int code) 63expect_absent (int code)
46{ 64{
47 return expect_result (code, "unknown"); 65 return expect_result (code, r_unknown);
48} 66}
49 67
50 68