Mercurial > dovecot > core-2.2
annotate src/lib-http/test-http-client-errors.c @ 22633:9284bdc3c5c5
director: Don't recreate timeout on every user lookup
Recreate it only when the timeout should change.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Sat, 04 Nov 2017 01:34:02 +0200 |
parents | a0112b13e73c |
children | cb108f786fb4 |
rev | line source |
---|---|
21390
2e2563132d5f
Updated copyright notices to include the year 2017.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21389
diff
changeset
|
1 /* Copyright (c) 2016-2017 Dovecot authors, see the included COPYING file */ |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3 #include "lib.h" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
4 #include "str.h" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
5 #include "hostpid.h" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
6 #include "ioloop.h" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
7 #include "istream.h" |
21026
5a0044accf49
lib-http: Made test-http-client-errors more reliable.
Stephan Bosch <stephan@dovecot.fi>
parents:
20365
diff
changeset
|
8 #include "istream-chain.h" |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
9 #include "ostream.h" |
20362
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
10 #include "time-util.h" |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
11 #include "connection.h" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
12 #include "test-common.h" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
13 #include "http-url.h" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
14 #include "http-request.h" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
15 #include "http-client.h" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
16 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
17 #include <sys/types.h> |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
18 #include <sys/wait.h> |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
19 #include <signal.h> |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
20 #include <unistd.h> |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
21 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
22 /* |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
23 * Types |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
24 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
25 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
26 struct server_connection { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
27 struct connection conn; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
28 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
29 pool_t pool; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
30 }; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
31 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
32 typedef void (*test_server_init_t)(unsigned int index); |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
33 typedef bool (*test_client_init_t) |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
34 (const struct http_client_settings *client_set); |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
35 typedef void (*test_dns_init_t)(void); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
36 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
37 /* |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
38 * State |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
39 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
40 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
41 /* common */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
42 static struct ip_addr bind_ip; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
43 static in_port_t *bind_ports = 0; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
44 static struct ioloop *ioloop; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
45 static bool debug = FALSE; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
46 |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
47 /* dns */ |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
48 static pid_t dns_pid = (pid_t)-1; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
49 |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
50 /* server */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
51 static struct io *io_listen; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
52 static int fd_listen = -1; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
53 static pid_t *server_pids = NULL; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
54 static unsigned int server_pids_count = 0; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
55 static struct connection_list *server_conn_list; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
56 static size_t server_read_max = 0; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
57 static unsigned int server_index; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
58 static void (*test_server_input)(struct server_connection *conn); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
59 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
60 /* client */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
61 static struct http_client *http_client = NULL; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
62 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
63 /* |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
64 * Forward declarations |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
65 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
66 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
67 /* server */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
68 static void test_server_run(unsigned int index); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
69 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
70 server_connection_deinit(struct server_connection **_conn); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
71 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
72 /* client */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
73 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
74 test_client_defaults(struct http_client_settings *http_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
75 static void test_client_deinit(void); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
76 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
77 /* test*/ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
78 static void test_run_client_server( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
79 const struct http_client_settings *client_set, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
80 test_client_init_t client_test, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
81 test_server_init_t server_test, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
82 unsigned int server_tests_count, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
83 test_dns_init_t dns_test) |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
84 ATTR_NULL(3); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
85 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
86 /* |
21789
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
87 * Unconfigured SSL |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
88 */ |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
89 |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
90 /* client */ |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
91 |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
92 struct _unconfigured_ssl { |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
93 unsigned int count; |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
94 }; |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
95 |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
96 static void |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
97 test_client_unconfigured_ssl_response( |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
98 const struct http_response *resp, |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
99 struct _unconfigured_ssl *ctx) |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
100 { |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
101 if (debug) |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
102 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
103 |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
104 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_CONNECT_FAILED); |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
105 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
106 |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
107 if (--ctx->count == 0) { |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
108 i_free(ctx); |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
109 io_loop_stop(ioloop); |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
110 } |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
111 } |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
112 |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
113 static bool |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
114 test_client_unconfigured_ssl(const struct http_client_settings *client_set) |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
115 { |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
116 struct http_client_request *hreq; |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
117 struct _unconfigured_ssl *ctx; |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
118 |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
119 ctx = i_new(struct _unconfigured_ssl, 1); |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
120 ctx->count = 2; |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
121 |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
122 http_client = http_client_init(client_set); |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
123 |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
124 hreq = http_client_request(http_client, |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
125 "GET", "127.0.0.1", "/unconfigured-ssl.txt", |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
126 test_client_unconfigured_ssl_response, ctx); |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
127 http_client_request_set_ssl(hreq, TRUE); |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
128 http_client_request_submit(hreq); |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
129 |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
130 hreq = http_client_request(http_client, |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
131 "GET", "127.0.0.1", "/unconfigured-ssl2.txt", |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
132 test_client_unconfigured_ssl_response, ctx); |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
133 http_client_request_set_ssl(hreq, TRUE); |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
134 http_client_request_submit(hreq); |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
135 |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
136 return TRUE; |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
137 } |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
138 |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
139 /* test */ |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
140 |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
141 static void test_unconfigured_ssl(void) |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
142 { |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
143 struct http_client_settings http_client_set; |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
144 |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
145 test_client_defaults(&http_client_set); |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
146 |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
147 test_begin("unconfigured ssl"); |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
148 test_run_client_server(&http_client_set, |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
149 test_client_unconfigured_ssl, |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
150 NULL, 0, NULL); |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
151 test_end(); |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
152 } |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
153 |
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
154 /* |
21827
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
155 * Unconfigured SSL abort |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
156 */ |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
157 |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
158 /* client */ |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
159 |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
160 struct _unconfigured_ssl_abort { |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
161 unsigned int count; |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
162 }; |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
163 |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
164 static void |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
165 test_client_unconfigured_ssl_abort_response1( |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
166 const struct http_response *resp, |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
167 struct _unconfigured_ssl_abort *ctx ATTR_UNUSED) |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
168 { |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
169 if (debug) |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
170 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
171 |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
172 test_out_quiet("inappropriate callback", FALSE); |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
173 } |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
174 |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
175 static void |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
176 test_client_unconfigured_ssl_abort_response2( |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
177 const struct http_response *resp, |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
178 struct _unconfigured_ssl_abort *ctx) |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
179 { |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
180 if (debug) |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
181 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
182 |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
183 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_CONNECT_FAILED); |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
184 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
185 |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
186 i_free(ctx); |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
187 io_loop_stop(ioloop); |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
188 } |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
189 |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
190 static bool |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
191 test_client_unconfigured_ssl_abort(const struct http_client_settings *client_set) |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
192 { |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
193 struct http_client_request *hreq; |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
194 struct _unconfigured_ssl_abort *ctx; |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
195 |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
196 ctx = i_new(struct _unconfigured_ssl_abort, 1); |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
197 ctx->count = 1; |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
198 |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
199 http_client = http_client_init(client_set); |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
200 |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
201 hreq = http_client_request(http_client, |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
202 "GET", "127.0.0.1", "/unconfigured-ssl.txt", |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
203 test_client_unconfigured_ssl_abort_response1, ctx); |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
204 http_client_request_set_ssl(hreq, TRUE); |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
205 http_client_request_submit(hreq); |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
206 http_client_request_abort(&hreq); |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
207 |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
208 hreq = http_client_request(http_client, |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
209 "GET", "127.0.0.1", "/unconfigured-ssl2.txt", |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
210 test_client_unconfigured_ssl_abort_response2, ctx); |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
211 http_client_request_set_ssl(hreq, TRUE); |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
212 http_client_request_submit(hreq); |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
213 |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
214 return TRUE; |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
215 } |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
216 |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
217 /* test */ |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
218 |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
219 static void test_unconfigured_ssl_abort(void) |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
220 { |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
221 struct http_client_settings http_client_set; |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
222 |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
223 test_client_defaults(&http_client_set); |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
224 |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
225 test_begin("unconfigured ssl abort"); |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
226 test_run_client_server(&http_client_set, |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
227 test_client_unconfigured_ssl_abort, |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
228 NULL, 0, NULL); |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
229 test_end(); |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
230 } |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
231 |
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
232 /* |
21793
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
233 * Invalid URL |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
234 */ |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
235 |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
236 /* client */ |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
237 |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
238 struct _invalid_url { |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
239 unsigned int count; |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
240 }; |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
241 |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
242 static void |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
243 test_client_invalid_url_response( |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
244 const struct http_response *resp, |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
245 struct _invalid_url *ctx) |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
246 { |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
247 if (debug) |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
248 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
249 |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
250 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_INVALID_URL); |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
251 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
252 |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
253 if (--ctx->count == 0) { |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
254 i_free(ctx); |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
255 io_loop_stop(ioloop); |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
256 } |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
257 } |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
258 |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
259 static bool |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
260 test_client_invalid_url(const struct http_client_settings *client_set) |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
261 { |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
262 struct http_client_request *hreq; |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
263 struct _invalid_url *ctx; |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
264 |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
265 ctx = i_new(struct _invalid_url, 1); |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
266 ctx->count = 2; |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
267 |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
268 http_client = http_client_init(client_set); |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
269 |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
270 hreq = http_client_request_url_str(http_client, |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
271 "GET", "imap://example.com/INBOX", |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
272 test_client_invalid_url_response, ctx); |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
273 http_client_request_submit(hreq); |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
274 |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
275 hreq = http_client_request_url_str(http_client, |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
276 "GET", "http:/www.example.com", |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
277 test_client_invalid_url_response, ctx); |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
278 http_client_request_submit(hreq); |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
279 |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
280 return TRUE; |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
281 } |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
282 |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
283 /* test */ |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
284 |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
285 static void test_invalid_url(void) |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
286 { |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
287 struct http_client_settings http_client_set; |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
288 |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
289 test_client_defaults(&http_client_set); |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
290 |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
291 test_begin("invalid url"); |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
292 test_run_client_server(&http_client_set, |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
293 test_client_invalid_url, |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
294 NULL, 0, NULL); |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
295 test_end(); |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
296 } |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
297 |
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
298 /* |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
299 * Host lookup failed |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
300 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
301 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
302 /* client */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
303 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
304 struct _host_lookup_failed { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
305 unsigned int count; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
306 }; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
307 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
308 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
309 test_client_host_lookup_failed_response( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
310 const struct http_response *resp, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
311 struct _host_lookup_failed *ctx) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
312 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
313 if (debug) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
314 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
315 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
316 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_HOST_LOOKUP_FAILED); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
317 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
318 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
319 if (--ctx->count == 0) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
320 i_free(ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
321 io_loop_stop(ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
322 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
323 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
324 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
325 static bool |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
326 test_client_host_lookup_failed(const struct http_client_settings *client_set) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
327 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
328 struct http_client_request *hreq; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
329 struct _host_lookup_failed *ctx; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
330 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
331 ctx = i_new(struct _host_lookup_failed, 1); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
332 ctx->count = 2; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
333 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
334 http_client = http_client_init(client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
335 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
336 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
337 "GET", "host.in-addr.arpa", "/host-lookup-failed.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
338 test_client_host_lookup_failed_response, ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
339 http_client_request_submit(hreq); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
340 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
341 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
342 "GET", "host.in-addr.arpa", "/host-lookup-failed2.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
343 test_client_host_lookup_failed_response, ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
344 http_client_request_submit(hreq); |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
345 |
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
346 return TRUE; |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
347 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
348 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
349 /* test */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
350 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
351 static void test_host_lookup_failed(void) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
352 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
353 struct http_client_settings http_client_set; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
354 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
355 test_client_defaults(&http_client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
356 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
357 test_begin("host lookup failed"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
358 test_run_client_server(&http_client_set, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
359 test_client_host_lookup_failed, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
360 NULL, 0, NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
361 test_end(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
362 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
363 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
364 /* |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
365 * Connection refused |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
366 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
367 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
368 /* server */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
369 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
370 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
371 test_server_connection_refused(unsigned int index ATTR_UNUSED) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
372 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
373 i_close_fd(&fd_listen); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
374 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
375 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
376 /* client */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
377 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
378 struct _connection_refused { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
379 unsigned int count; |
21335
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
380 struct timeout *to; |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
381 }; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
382 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
383 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
384 test_client_connection_refused_response( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
385 const struct http_response *resp, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
386 struct _connection_refused *ctx) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
387 { |
21335
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
388 test_assert(ctx->to == NULL); |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
389 if (ctx->to != NULL) |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
390 timeout_remove(&ctx->to); |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
391 |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
392 if (debug) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
393 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
394 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
395 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_CONNECT_FAILED); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
396 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
397 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
398 if (--ctx->count == 0) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
399 i_free(ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
400 io_loop_stop(ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
401 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
402 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
403 |
21335
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
404 static void |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
405 test_client_connection_refused_timeout(struct _connection_refused *ctx) |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
406 { |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
407 if (debug) |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
408 i_debug("TIMEOUT (ok)"); |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
409 timeout_remove(&ctx->to); |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
410 } |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
411 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
412 static bool |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
413 test_client_connection_refused(const struct http_client_settings *client_set) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
414 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
415 struct http_client_request *hreq; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
416 struct _connection_refused *ctx; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
417 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
418 ctx = i_new(struct _connection_refused, 1); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
419 ctx->count = 2; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
420 |
21335
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
421 if (client_set->max_connect_attempts > 0) { |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
422 ctx->to = timeout_add_short(250, |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
423 test_client_connection_refused_timeout, ctx); |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
424 } |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
425 |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
426 http_client = http_client_init(client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
427 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
428 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
429 "GET", net_ip2addr(&bind_ip), "/connection-refused.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
430 test_client_connection_refused_response, ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
431 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
432 http_client_request_submit(hreq); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
433 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
434 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
435 "GET", net_ip2addr(&bind_ip), "/connection-refused2.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
436 test_client_connection_refused_response, ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
437 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
438 http_client_request_submit(hreq); |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
439 |
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
440 return TRUE; |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
441 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
442 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
443 /* test */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
444 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
445 static void test_connection_refused(void) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
446 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
447 struct http_client_settings http_client_set; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
448 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
449 test_client_defaults(&http_client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
450 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
451 test_begin("connection refused"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
452 test_run_client_server(&http_client_set, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
453 test_client_connection_refused, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
454 test_server_connection_refused, 1, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
455 NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
456 test_end(); |
21335
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
457 |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
458 http_client_set.max_connect_attempts = 3; |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
459 |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
460 test_begin("connection refused backoff"); |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
461 test_run_client_server(&http_client_set, |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
462 test_client_connection_refused, |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
463 test_server_connection_refused, 1, |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
464 NULL); |
aeadca02bfe1
lib-http: client: Added test for normal connection backoff behavior to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21263
diff
changeset
|
465 test_end(); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
466 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
467 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
468 /* |
21336
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
469 * Connection lost prematurely |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
470 */ |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
471 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
472 /* server */ |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
473 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
474 static void |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
475 test_server_connection_lost_prematurely_input(struct server_connection *conn) |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
476 { |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
477 server_connection_deinit(&conn); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
478 } |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
479 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
480 static void |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
481 test_server_connection_lost_prematurely(unsigned int index) |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
482 { |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
483 test_server_input = test_server_connection_lost_prematurely_input; |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
484 test_server_run(index); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
485 } |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
486 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
487 /* client */ |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
488 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
489 struct _connection_lost_prematurely { |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
490 unsigned int count; |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
491 struct timeout *to; |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
492 }; |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
493 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
494 static void |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
495 test_client_connection_lost_prematurely_response( |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
496 const struct http_response *resp, |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
497 struct _connection_lost_prematurely *ctx) |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
498 { |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
499 test_assert(ctx->to == NULL); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
500 if (ctx->to != NULL) |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
501 timeout_remove(&ctx->to); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
502 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
503 if (debug) |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
504 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
505 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
506 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_CONNECTION_LOST); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
507 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
508 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
509 if (--ctx->count == 0) { |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
510 i_free(ctx); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
511 io_loop_stop(ioloop); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
512 } |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
513 } |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
514 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
515 static void |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
516 test_client_connection_lost_prematurely_timeout( |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
517 struct _connection_lost_prematurely *ctx) |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
518 { |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
519 if (debug) |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
520 i_debug("TIMEOUT (ok)"); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
521 timeout_remove(&ctx->to); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
522 } |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
523 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
524 static bool |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
525 test_client_connection_lost_prematurely(const struct http_client_settings *client_set) |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
526 { |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
527 struct http_client_request *hreq; |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
528 struct _connection_lost_prematurely *ctx; |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
529 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
530 ctx = i_new(struct _connection_lost_prematurely, 1); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
531 ctx->count = 2; |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
532 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
533 ctx->to = timeout_add_short(250, |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
534 test_client_connection_lost_prematurely_timeout, ctx); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
535 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
536 http_client = http_client_init(client_set); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
537 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
538 hreq = http_client_request(http_client, |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
539 "GET", net_ip2addr(&bind_ip), "/connection-refused-retry.txt", |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
540 test_client_connection_lost_prematurely_response, ctx); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
541 http_client_request_set_port(hreq, bind_ports[0]); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
542 http_client_request_submit(hreq); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
543 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
544 hreq = http_client_request(http_client, |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
545 "GET", net_ip2addr(&bind_ip), "/connection-refused-retry2.txt", |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
546 test_client_connection_lost_prematurely_response, ctx); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
547 http_client_request_set_port(hreq, bind_ports[0]); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
548 http_client_request_submit(hreq); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
549 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
550 return TRUE; |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
551 } |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
552 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
553 /* test */ |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
554 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
555 static void test_connection_lost_prematurely(void) |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
556 { |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
557 struct http_client_settings http_client_set; |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
558 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
559 test_client_defaults(&http_client_set); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
560 http_client_set.max_connect_attempts = 3; |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
561 http_client_set.max_attempts = 3; |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
562 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
563 test_begin("connection lost prematurely"); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
564 test_run_client_server(&http_client_set, |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
565 test_client_connection_lost_prematurely, |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
566 test_server_connection_lost_prematurely, 1, |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
567 NULL); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
568 test_end(); |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
569 } |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
570 |
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
571 /* |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
572 * Connection timed out |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
573 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
574 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
575 /* client */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
576 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
577 struct _connection_timed_out { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
578 unsigned int count; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
579 }; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
580 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
581 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
582 test_client_connection_timed_out_response( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
583 const struct http_response *resp, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
584 struct _connection_timed_out *ctx) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
585 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
586 if (debug) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
587 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
588 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
589 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_CONNECT_FAILED); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
590 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
591 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
592 if (--ctx->count == 0) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
593 i_free(ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
594 io_loop_stop(ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
595 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
596 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
597 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
598 static bool |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
599 test_client_connection_timed_out( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
600 const struct http_client_settings *client_set) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
601 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
602 struct http_client_request *hreq; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
603 struct _connection_timed_out *ctx; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
604 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
605 ctx = i_new(struct _connection_timed_out, 1); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
606 ctx->count = 2; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
607 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
608 http_client = http_client_init(client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
609 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
610 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
611 "GET", "192.168.0.0", "/connection-timed-out.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
612 test_client_connection_timed_out_response, ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
613 http_client_request_submit(hreq); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
614 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
615 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
616 "GET", "192.168.0.0", "/connection-timed-out2.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
617 test_client_connection_timed_out_response, ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
618 http_client_request_submit(hreq); |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
619 |
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
620 return TRUE; |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
621 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
622 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
623 /* test */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
624 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
625 static void test_connection_timed_out(void) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
626 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
627 struct http_client_settings http_client_set; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
628 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
629 test_client_defaults(&http_client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
630 http_client_set.connect_timeout_msecs = 1000; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
631 http_client_set.max_attempts = 1; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
632 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
633 test_begin("connection timed out"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
634 test_run_client_server(&http_client_set, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
635 test_client_connection_timed_out, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
636 NULL, 0, NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
637 test_end(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
638 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
639 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
640 /* |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
641 * Invalid redirect |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
642 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
643 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
644 /* server */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
645 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
646 /* -> not accepted */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
647 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
648 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
649 test_invalid_redirect_input1(struct server_connection *conn) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
650 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
651 static const char *resp = |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
652 "HTTP/1.1 302 Redirect\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
653 "Location: http://localhost:4444\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
654 "\r\n"; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
655 o_stream_nsend_str(conn->conn.output, resp); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
656 server_connection_deinit(&conn); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
657 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
658 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
659 static void test_server_invalid_redirect1(unsigned int index) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
660 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
661 test_server_input = test_invalid_redirect_input1; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
662 test_server_run(index); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
663 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
664 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
665 /* -> bad location */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
666 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
667 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
668 test_invalid_redirect_input2(struct server_connection *conn) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
669 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
670 static const char *resp = |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
671 "HTTP/1.1 302 Redirect\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
672 "Location: unix:/var/run/dovecot/auth-master\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
673 "\r\n"; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
674 o_stream_nsend_str(conn->conn.output, resp); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
675 server_connection_deinit(&conn); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
676 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
677 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
678 static void test_server_invalid_redirect2(unsigned int index) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
679 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
680 test_server_input = test_invalid_redirect_input2; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
681 test_server_run(index); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
682 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
683 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
684 /* -> too many */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
685 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
686 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
687 test_invalid_redirect_input3(struct server_connection *conn) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
688 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
689 string_t *resp; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
690 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
691 resp = t_str_new(512); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
692 str_printfa(resp, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
693 "HTTP/1.1 302 Redirect\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
694 "Location: http://%s:%u/friep.txt\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
695 "\r\n", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
696 net_ip2addr(&bind_ip), bind_ports[server_index+1]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
697 o_stream_nsend(conn->conn.output, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
698 str_data(resp), str_len(resp)); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
699 server_connection_deinit(&conn); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
700 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
701 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
702 static void test_server_invalid_redirect3(unsigned int index) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
703 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
704 test_server_input = test_invalid_redirect_input3; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
705 test_server_run(index); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
706 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
707 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
708 /* client */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
709 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
710 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
711 test_client_invalid_redirect_response( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
712 const struct http_response *resp, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
713 void *context ATTR_UNUSED) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
714 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
715 if (debug) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
716 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
717 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
718 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_INVALID_REDIRECT); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
719 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
720 io_loop_stop(ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
721 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
722 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
723 static bool |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
724 test_client_invalid_redirect(const struct http_client_settings *client_set) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
725 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
726 struct http_client_request *hreq; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
727 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
728 http_client = http_client_init(client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
729 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
730 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
731 "GET", net_ip2addr(&bind_ip), "/invalid-redirect.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
732 test_client_invalid_redirect_response, NULL); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
733 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
734 http_client_request_submit(hreq); |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
735 |
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
736 return TRUE; |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
737 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
738 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
739 /* test */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
740 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
741 static void test_invalid_redirect(void) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
742 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
743 struct http_client_settings http_client_set; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
744 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
745 test_client_defaults(&http_client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
746 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
747 test_begin("invalid redirect: not accepted"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
748 http_client_set.max_redirects = 0; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
749 test_run_client_server(&http_client_set, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
750 test_client_invalid_redirect, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
751 test_server_invalid_redirect1, 1, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
752 NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
753 test_end(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
754 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
755 test_begin("invalid redirect: bad location"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
756 http_client_set.max_redirects = 1; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
757 test_run_client_server(&http_client_set, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
758 test_client_invalid_redirect, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
759 test_server_invalid_redirect2, 1, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
760 NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
761 test_end(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
762 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
763 test_begin("invalid redirect: too many"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
764 http_client_set.max_redirects = 1; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
765 test_run_client_server(&http_client_set, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
766 test_client_invalid_redirect, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
767 test_server_invalid_redirect3, 3, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
768 NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
769 test_end(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
770 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
771 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
772 /* |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
773 * Unseekable redirect |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
774 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
775 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
776 /* server */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
777 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
778 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
779 test_unseekable_redirect_input(struct server_connection *conn) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
780 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
781 string_t *resp; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
782 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
783 resp = t_str_new(512); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
784 str_printfa(resp, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
785 "HTTP/1.1 302 Redirect\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
786 "Location: http://%s:%u/frml.txt\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
787 "\r\n", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
788 net_ip2addr(&bind_ip), bind_ports[server_index+1]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
789 o_stream_nsend(conn->conn.output, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
790 str_data(resp), str_len(resp)); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
791 server_connection_deinit(&conn); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
792 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
793 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
794 static void test_server_unseekable_redirect(unsigned int index) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
795 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
796 test_server_input = test_unseekable_redirect_input; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
797 test_server_run(index); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
798 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
799 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
800 /* client */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
801 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
802 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
803 test_client_unseekable_redirect_response( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
804 const struct http_response *resp, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
805 void *context ATTR_UNUSED) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
806 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
807 if (debug) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
808 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
809 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
810 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_ABORTED); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
811 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
812 io_loop_stop(ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
813 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
814 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
815 static bool |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
816 test_client_unseekable_redirect(const struct http_client_settings *client_set) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
817 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
818 struct http_client_request *hreq; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
819 struct istream *input; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
820 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
821 http_client = http_client_init(client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
822 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
823 input = i_stream_create_from_data("FROP", 4); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
824 input->seekable = FALSE; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
825 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
826 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
827 "GET", net_ip2addr(&bind_ip), "/unseekable-redirect.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
828 test_client_unseekable_redirect_response, NULL); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
829 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
830 http_client_request_set_payload(hreq, input, FALSE); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
831 http_client_request_submit(hreq); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
832 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
833 i_stream_unref(&input); |
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
834 return TRUE; |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
835 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
836 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
837 /* test */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
838 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
839 static void test_unseekable_redirect(void) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
840 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
841 struct http_client_settings http_client_set; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
842 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
843 test_client_defaults(&http_client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
844 http_client_set.max_redirects = 1; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
845 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
846 test_begin("unseekable redirect"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
847 test_run_client_server(&http_client_set, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
848 test_client_unseekable_redirect, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
849 test_server_unseekable_redirect, 2, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
850 NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
851 test_end(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
852 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
853 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
854 /* |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
855 * Unseekable retry |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
856 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
857 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
858 /* server */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
859 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
860 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
861 test_unseekable_retry_input(struct server_connection *conn) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
862 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
863 server_connection_deinit(&conn); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
864 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
865 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
866 static void test_server_unseekable_retry(unsigned int index) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
867 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
868 test_server_input = test_unseekable_retry_input; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
869 test_server_run(index); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
870 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
871 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
872 /* client */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
873 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
874 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
875 test_client_unseekable_retry_response( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
876 const struct http_response *resp, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
877 void *context ATTR_UNUSED) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
878 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
879 if (debug) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
880 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
881 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
882 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_ABORTED); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
883 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
884 io_loop_stop(ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
885 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
886 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
887 static bool |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
888 test_client_unseekable_retry(const struct http_client_settings *client_set) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
889 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
890 struct http_client_request *hreq; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
891 struct istream *input; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
892 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
893 http_client = http_client_init(client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
894 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
895 input = i_stream_create_from_data("FROP", 4); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
896 input->seekable = FALSE; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
897 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
898 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
899 "GET", net_ip2addr(&bind_ip), "/unseekable-retry.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
900 test_client_unseekable_retry_response, NULL); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
901 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
902 http_client_request_set_payload(hreq, input, FALSE); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
903 http_client_request_submit(hreq); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
904 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
905 i_stream_unref(&input); |
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
906 return TRUE; |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
907 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
908 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
909 /* test */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
910 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
911 static void test_unseekable_retry(void) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
912 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
913 struct http_client_settings http_client_set; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
914 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
915 test_client_defaults(&http_client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
916 http_client_set.max_attempts = 3; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
917 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
918 test_begin("unseekable retry"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
919 test_run_client_server(&http_client_set, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
920 test_client_unseekable_retry, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
921 test_server_unseekable_retry, 2, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
922 NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
923 test_end(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
924 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
925 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
926 /* |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
927 * Broken payload |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
928 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
929 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
930 /* server */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
931 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
932 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
933 test_broken_payload_input(struct server_connection *conn) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
934 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
935 static const char *resp = |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
936 "HTTP/1.1 200 OK\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
937 "Content-Length: 18\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
938 "\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
939 "Everything is OK\r\n"; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
940 o_stream_nsend_str(conn->conn.output, resp); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
941 server_connection_deinit(&conn); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
942 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
943 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
944 static void test_server_broken_payload(unsigned int index) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
945 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
946 test_server_input = test_broken_payload_input; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
947 test_server_run(index); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
948 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
949 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
950 /* client */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
951 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
952 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
953 test_client_broken_payload_response( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
954 const struct http_response *resp, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
955 void *context ATTR_UNUSED) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
956 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
957 if (debug) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
958 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
959 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
960 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_BROKEN_PAYLOAD); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
961 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
962 io_loop_stop(ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
963 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
964 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
965 static bool |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
966 test_client_broken_payload(const struct http_client_settings *client_set) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
967 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
968 struct http_client_request *hreq; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
969 struct istream *input; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
970 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
971 test_expect_errors(1); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
972 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
973 http_client = http_client_init(client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
974 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
975 input = i_stream_create_error_str(EIO, "Moehahahaha!!"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
976 i_stream_set_name(input, "PURE EVIL"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
977 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
978 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
979 "GET", net_ip2addr(&bind_ip), "/broken-payload.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
980 test_client_broken_payload_response, NULL); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
981 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
982 http_client_request_set_payload(hreq, input, FALSE); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
983 http_client_request_submit(hreq); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
984 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
985 i_stream_unref(&input); |
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
986 return TRUE; |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
987 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
988 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
989 /* test */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
990 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
991 static void test_broken_payload(void) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
992 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
993 struct http_client_settings http_client_set; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
994 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
995 test_client_defaults(&http_client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
996 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
997 test_begin("broken payload"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
998 test_run_client_server(&http_client_set, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
999 test_client_broken_payload, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1000 test_server_broken_payload, 1, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1001 NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1002 test_end(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1003 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1004 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1005 /* |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1006 * Connection lost |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1007 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1008 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1009 /* server */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1010 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1011 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1012 test_connection_lost_input(struct server_connection *conn) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1013 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1014 ssize_t ret; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1015 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1016 if (server_read_max == 0) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1017 server_connection_deinit(&conn); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1018 return; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1019 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1020 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1021 i_stream_set_max_buffer_size(conn->conn.input, server_read_max); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1022 ret = i_stream_read(conn->conn.input); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1023 if (ret == -2) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1024 server_connection_deinit(&conn); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1025 return; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1026 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1027 if (ret < 0) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1028 if (i_stream_is_eof(conn->conn.input)) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1029 i_fatal("server: Client stream ended prematurely"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1030 else |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1031 i_fatal("server: Streem error: %s", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1032 i_stream_get_error(conn->conn.input)); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1033 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1034 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1035 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1036 static void test_server_connection_lost(unsigned int index) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1037 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1038 test_server_input = test_connection_lost_input; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1039 test_server_run(index); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1040 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1041 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1042 /* client */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1043 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1044 struct _connection_lost_ctx { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1045 unsigned int count; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1046 }; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1047 |
20365
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1048 struct _connection_lost_request_ctx { |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1049 struct _connection_lost_ctx *ctx; |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1050 struct http_client_request *req; |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1051 }; |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1052 |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1053 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1054 test_client_connection_lost_response( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1055 const struct http_response *resp, |
20365
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1056 struct _connection_lost_request_ctx *rctx) |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1057 { |
20365
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1058 struct _connection_lost_ctx *ctx = rctx->ctx; |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1059 |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1060 if (debug) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1061 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1062 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1063 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_CONNECTION_LOST); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1064 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1065 |
20365
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1066 if (http_client_request_try_retry(rctx->req)) { |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1067 if (debug) |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1068 i_debug("retrying"); |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1069 return; |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1070 } |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1071 i_free(rctx); |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1072 |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1073 if (--ctx->count == 0) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1074 i_free(ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1075 io_loop_stop(ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1076 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1077 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1078 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
1079 static bool |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1080 test_client_connection_lost(const struct http_client_settings *client_set) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1081 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1082 static const char payload[] = |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1083 "This is a useless payload that only serves as a means to give the " |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1084 "server the opportunity to close the connection before the payload " |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1085 "is finished."; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1086 struct _connection_lost_ctx *ctx; |
20365
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1087 struct _connection_lost_request_ctx *rctx; |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1088 struct http_client_request *hreq; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1089 struct istream *input; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1090 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1091 ctx = i_new(struct _connection_lost_ctx, 1); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1092 ctx->count = 2; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1093 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1094 http_client = http_client_init(client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1095 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1096 input = i_stream_create_from_data(payload, sizeof(payload)-1); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1097 |
20365
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1098 rctx = i_new(struct _connection_lost_request_ctx, 1); |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1099 rctx->ctx = ctx; |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1100 |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1101 rctx->req = hreq = http_client_request(http_client, |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1102 "GET", net_ip2addr(&bind_ip), "/connection-lost.txt", |
20365
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1103 test_client_connection_lost_response, rctx); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1104 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1105 http_client_request_set_payload(hreq, input, FALSE); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1106 http_client_request_submit(hreq); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1107 |
20365
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1108 rctx = i_new(struct _connection_lost_request_ctx, 1); |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1109 rctx->ctx = ctx; |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1110 |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1111 rctx->req = hreq = http_client_request(http_client, |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1112 "GET", net_ip2addr(&bind_ip), "/connection-lost2.txt", |
20365
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1113 test_client_connection_lost_response, rctx); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1114 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1115 http_client_request_submit(hreq); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1116 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
1117 i_stream_unref(&input); |
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
1118 return TRUE; |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1119 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1120 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1121 /* test */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1122 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1123 static void test_connection_lost(void) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1124 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1125 struct http_client_settings http_client_set; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1126 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1127 test_client_defaults(&http_client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1128 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1129 server_read_max = 0; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1130 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1131 test_begin("connection lost: one attempt"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1132 http_client_set.max_attempts = 1; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1133 test_run_client_server(&http_client_set, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1134 test_client_connection_lost, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1135 test_server_connection_lost, 1, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1136 NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1137 test_end(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1138 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1139 test_begin("connection lost: two attempts"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1140 http_client_set.max_attempts = 2; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1141 test_run_client_server(&http_client_set, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1142 test_client_connection_lost, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1143 test_server_connection_lost, 1, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1144 NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1145 test_end(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1146 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1147 test_begin("connection lost: three attempts"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1148 http_client_set.max_attempts = 3; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1149 test_run_client_server(&http_client_set, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1150 test_client_connection_lost, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1151 test_server_connection_lost, 1, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1152 NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1153 test_end(); |
20365
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1154 |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1155 test_begin("connection lost: manual retry"); |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1156 http_client_set.max_attempts = 3; |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1157 http_client_set.no_auto_retry = TRUE; |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1158 test_run_client_server(&http_client_set, |
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1159 test_client_connection_lost, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1160 test_server_connection_lost, 1, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1161 NULL); |
20365
c0ec6c81852d
lib-http: client: Added tests for manual handling of connection loss retries to test-http-client-errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20362
diff
changeset
|
1162 test_end(); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1163 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1164 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1165 /* |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1166 * Connection lost after 100-continue |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1167 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1168 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1169 /* server */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1170 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1171 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1172 test_connection_lost_100_input(struct server_connection *conn) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1173 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1174 static const char *resp = |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1175 "HTTP/1.1 100 Continue\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1176 "\r\n"; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1177 o_stream_nsend_str(conn->conn.output, resp); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1178 server_connection_deinit(&conn); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1179 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1180 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1181 static void test_server_connection_lost_100(unsigned int index) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1182 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1183 test_server_input = test_connection_lost_100_input; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1184 test_server_run(index); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1185 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1186 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1187 /* client */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1188 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1189 struct _connection_lost_100_ctx { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1190 unsigned int count; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1191 }; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1192 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1193 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1194 test_client_connection_lost_100_response( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1195 const struct http_response *resp, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1196 struct _connection_lost_100_ctx *ctx) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1197 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1198 if (debug) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1199 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1200 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1201 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_CONNECTION_LOST); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1202 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1203 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1204 if (--ctx->count == 0) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1205 i_free(ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1206 io_loop_stop(ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1207 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1208 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1209 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
1210 static bool |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1211 test_client_connection_lost_100( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1212 const struct http_client_settings *client_set) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1213 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1214 static const char payload[] = |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1215 "This is a useless payload that only serves as a means to give the " |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1216 "server the opportunity to close the connection before the payload " |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1217 "is finished."; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1218 struct _connection_lost_100_ctx *ctx; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1219 struct http_client_request *hreq; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1220 struct istream *input; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1221 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1222 ctx = i_new(struct _connection_lost_100_ctx, 1); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1223 ctx->count = 2; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1224 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1225 http_client = http_client_init(client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1226 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1227 input = i_stream_create_from_data(payload, sizeof(payload)-1); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1228 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1229 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1230 "GET", net_ip2addr(&bind_ip), "/connection-lost.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1231 test_client_connection_lost_100_response, ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1232 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1233 http_client_request_set_payload(hreq, input, TRUE); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1234 http_client_request_submit(hreq); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1235 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1236 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1237 "GET", net_ip2addr(&bind_ip), "/connection-lost2.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1238 test_client_connection_lost_100_response, ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1239 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1240 http_client_request_set_payload(hreq, input, TRUE); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1241 http_client_request_submit(hreq); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1242 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
1243 i_stream_unref(&input); |
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
1244 return TRUE; |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1245 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1246 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1247 /* test */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1248 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1249 static void test_connection_lost_100(void) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1250 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1251 struct http_client_settings http_client_set; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1252 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1253 test_client_defaults(&http_client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1254 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1255 server_read_max = 0; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1256 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1257 test_begin("connection lost after 100-continue"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1258 http_client_set.max_attempts = 1; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1259 test_run_client_server(&http_client_set, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1260 test_client_connection_lost_100, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1261 test_server_connection_lost_100, 1, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1262 NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1263 test_end(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1264 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1265 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1266 /* |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1267 * Connection lost in sub-ioloop |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1268 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1269 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1270 /* server */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1271 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1272 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1273 test_connection_lost_sub_ioloop_input(struct server_connection *conn) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1274 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1275 static const char *resp = |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1276 "HTTP/1.1 200 OK\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1277 "Content-Length: 0\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1278 "\r\n"; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1279 o_stream_nsend_str(conn->conn.output, resp); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1280 server_connection_deinit(&conn); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1281 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1282 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1283 static void test_server_connection_lost_sub_ioloop(unsigned int index) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1284 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1285 test_server_input = test_connection_lost_sub_ioloop_input; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1286 test_server_run(index); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1287 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1288 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1289 /* client */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1290 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1291 struct _connection_lost_sub_ioloop_ctx { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1292 unsigned int count; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1293 }; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1294 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1295 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1296 test_client_connection_lost_sub_ioloop_response2( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1297 const struct http_response *resp, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1298 struct ioloop *sub_ioloop) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1299 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1300 if (debug) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1301 i_debug("SUB-RESPONSE: %u %s", resp->status, resp->reason); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1302 io_loop_stop(sub_ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1303 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1304 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1305 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1306 test_client_connection_lost_sub_ioloop_response( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1307 const struct http_response *resp, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1308 struct _connection_lost_sub_ioloop_ctx *ctx) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1309 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1310 struct http_client_request *hreq; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1311 struct ioloop *sub_ioloop; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1312 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1313 if (debug) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1314 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1315 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1316 test_assert(resp->status == 200); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1317 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1318 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1319 sub_ioloop = io_loop_create(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1320 http_client_switch_ioloop(http_client); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1321 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1322 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1323 "GET", net_ip2addr(&bind_ip), "/connection-lost-sub-ioloop3.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1324 test_client_connection_lost_sub_ioloop_response2, sub_ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1325 http_client_request_set_port(hreq, bind_ports[1]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1326 http_client_request_submit(hreq); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1327 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1328 io_loop_run(sub_ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1329 io_loop_set_current(ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1330 http_client_switch_ioloop(http_client); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1331 io_loop_set_current(sub_ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1332 io_loop_destroy(&sub_ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1333 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1334 if (--ctx->count == 0) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1335 i_free(ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1336 io_loop_stop(ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1337 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1338 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1339 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
1340 static bool |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1341 test_client_connection_lost_sub_ioloop( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1342 const struct http_client_settings *client_set) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1343 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1344 static const char payload[] = |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1345 "This is a useless payload that only serves as a means to give the " |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1346 "server the opportunity to close the connection before the payload " |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1347 "is finished."; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1348 struct _connection_lost_sub_ioloop_ctx *ctx; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1349 struct http_client_request *hreq; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1350 struct istream *input; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1351 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1352 ctx = i_new(struct _connection_lost_sub_ioloop_ctx, 1); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1353 ctx->count = 2; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1354 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1355 http_client = http_client_init(client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1356 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1357 input = i_stream_create_from_data(payload, sizeof(payload)-1); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1358 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1359 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1360 "GET", net_ip2addr(&bind_ip), "/connection-lost-sub-ioloop.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1361 test_client_connection_lost_sub_ioloop_response, ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1362 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1363 http_client_request_set_payload(hreq, input, TRUE); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1364 http_client_request_submit(hreq); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1365 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1366 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1367 "GET", net_ip2addr(&bind_ip), "/connection-lost-sub-ioloop2.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1368 test_client_connection_lost_sub_ioloop_response, ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1369 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1370 http_client_request_set_payload(hreq, input, TRUE); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1371 http_client_request_submit(hreq); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1372 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
1373 i_stream_unref(&input); |
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
1374 return TRUE; |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1375 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1376 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1377 /* test */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1378 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1379 static void test_connection_lost_sub_ioloop(void) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1380 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1381 struct http_client_settings http_client_set; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1382 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1383 test_client_defaults(&http_client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1384 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1385 server_read_max = 0; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1386 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1387 test_begin("connection lost while running sub-ioloop"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1388 http_client_set.max_attempts = 1; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1389 test_run_client_server(&http_client_set, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1390 test_client_connection_lost_sub_ioloop, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1391 test_server_connection_lost_sub_ioloop, 2, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1392 NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1393 test_end(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1394 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1395 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1396 /* |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1397 * Early success |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1398 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1399 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1400 /* server */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1401 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1402 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1403 test_early_success_input(struct server_connection *conn) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1404 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1405 static const char *resp = |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1406 "HTTP/1.1 200 OK\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1407 "Content-Length: 18\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1408 "\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1409 "Everything is OK\r\n"; |
21026
5a0044accf49
lib-http: Made test-http-client-errors more reliable.
Stephan Bosch <stephan@dovecot.fi>
parents:
20365
diff
changeset
|
1410 |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1411 usleep(200000); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1412 o_stream_nsend_str(conn->conn.output, resp); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1413 server_connection_deinit(&conn); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1414 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1415 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1416 static void test_server_early_success(unsigned int index) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1417 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1418 test_server_input = test_early_success_input; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1419 test_server_run(index); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1420 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1421 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1422 /* client */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1423 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1424 struct _early_success_ctx { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1425 unsigned int count; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1426 }; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1427 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1428 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1429 test_client_early_success_response( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1430 const struct http_response *resp, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1431 struct _early_success_ctx *ctx) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1432 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1433 if (debug) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1434 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1435 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1436 if (ctx->count == 2) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1437 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_BAD_RESPONSE); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1438 else |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1439 test_assert(resp->status == 200); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1440 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1441 if (--ctx->count == 0) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1442 io_loop_stop(ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1443 i_free(ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1444 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1445 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1446 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
1447 static bool |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1448 test_client_early_success(const struct http_client_settings *client_set) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1449 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1450 struct http_client_request *hreq; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1451 struct _early_success_ctx *ctx; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1452 string_t *payload; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1453 unsigned int i; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1454 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1455 ctx = i_new(struct _early_success_ctx, 1); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1456 ctx->count = 2; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1457 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1458 http_client = http_client_init(client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1459 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1460 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1461 "GET", net_ip2addr(&bind_ip), "/early-success.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1462 test_client_early_success_response, ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1463 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1464 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1465 T_BEGIN { |
21026
5a0044accf49
lib-http: Made test-http-client-errors more reliable.
Stephan Bosch <stephan@dovecot.fi>
parents:
20365
diff
changeset
|
1466 struct istream_chain *chain; |
5a0044accf49
lib-http: Made test-http-client-errors more reliable.
Stephan Bosch <stephan@dovecot.fi>
parents:
20365
diff
changeset
|
1467 struct istream *input, *chain_input; |
5a0044accf49
lib-http: Made test-http-client-errors more reliable.
Stephan Bosch <stephan@dovecot.fi>
parents:
20365
diff
changeset
|
1468 |
5a0044accf49
lib-http: Made test-http-client-errors more reliable.
Stephan Bosch <stephan@dovecot.fi>
parents:
20365
diff
changeset
|
1469 payload = t_str_new(64*3000); |
5a0044accf49
lib-http: Made test-http-client-errors more reliable.
Stephan Bosch <stephan@dovecot.fi>
parents:
20365
diff
changeset
|
1470 for (i = 0; i < 3000; i++) { |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1471 str_append(payload, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1472 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1473 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\r\n"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1474 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1475 |
21026
5a0044accf49
lib-http: Made test-http-client-errors more reliable.
Stephan Bosch <stephan@dovecot.fi>
parents:
20365
diff
changeset
|
1476 chain_input = i_stream_create_chain(&chain); |
5a0044accf49
lib-http: Made test-http-client-errors more reliable.
Stephan Bosch <stephan@dovecot.fi>
parents:
20365
diff
changeset
|
1477 |
5a0044accf49
lib-http: Made test-http-client-errors more reliable.
Stephan Bosch <stephan@dovecot.fi>
parents:
20365
diff
changeset
|
1478 input = i_stream_create_copy_from_data |
5a0044accf49
lib-http: Made test-http-client-errors more reliable.
Stephan Bosch <stephan@dovecot.fi>
parents:
20365
diff
changeset
|
1479 (str_data(payload), str_len(payload)); |
5a0044accf49
lib-http: Made test-http-client-errors more reliable.
Stephan Bosch <stephan@dovecot.fi>
parents:
20365
diff
changeset
|
1480 i_stream_chain_append(chain, input); |
5a0044accf49
lib-http: Made test-http-client-errors more reliable.
Stephan Bosch <stephan@dovecot.fi>
parents:
20365
diff
changeset
|
1481 i_stream_unref(&input); |
5a0044accf49
lib-http: Made test-http-client-errors more reliable.
Stephan Bosch <stephan@dovecot.fi>
parents:
20365
diff
changeset
|
1482 |
5a0044accf49
lib-http: Made test-http-client-errors more reliable.
Stephan Bosch <stephan@dovecot.fi>
parents:
20365
diff
changeset
|
1483 http_client_request_set_payload(hreq, chain_input, FALSE); |
5a0044accf49
lib-http: Made test-http-client-errors more reliable.
Stephan Bosch <stephan@dovecot.fi>
parents:
20365
diff
changeset
|
1484 i_stream_unref(&chain_input); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1485 } T_END; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1486 http_client_request_submit(hreq); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1487 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1488 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1489 "GET", net_ip2addr(&bind_ip), "/early-success2.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1490 test_client_early_success_response, ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1491 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1492 http_client_request_submit(hreq); |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
1493 |
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
1494 return TRUE; |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1495 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1496 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1497 /* test */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1498 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1499 static void test_early_success(void) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1500 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1501 struct http_client_settings http_client_set; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1502 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1503 test_client_defaults(&http_client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1504 http_client_set.socket_send_buffer_size = 4096; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1505 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1506 test_begin("early succes"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1507 test_run_client_server(&http_client_set, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1508 test_client_early_success, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1509 test_server_early_success, 1, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1510 NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1511 test_end(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1512 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1513 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1514 /* |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1515 * Bad response |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1516 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1517 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1518 /* server */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1519 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1520 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1521 test_bad_response_input(struct server_connection *conn) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1522 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1523 static const char *resp = |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1524 "HTTP/1.1 666 Really bad response\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1525 "\r\n"; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1526 o_stream_nsend_str(conn->conn.output, resp); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1527 server_connection_deinit(&conn); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1528 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1529 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1530 static void test_server_bad_response(unsigned int index) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1531 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1532 test_server_input = test_bad_response_input; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1533 test_server_run(index); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1534 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1535 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1536 /* client */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1537 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1538 struct _bad_response_ctx { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1539 unsigned int count; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1540 }; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1541 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1542 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1543 test_client_bad_response_response( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1544 const struct http_response *resp, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1545 struct _bad_response_ctx *ctx) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1546 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1547 if (debug) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1548 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1549 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1550 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_BAD_RESPONSE); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1551 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1552 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1553 if (--ctx->count == 0) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1554 i_free(ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1555 io_loop_stop(ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1556 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1557 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1558 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
1559 static bool |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1560 test_client_bad_response(const struct http_client_settings *client_set) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1561 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1562 struct http_client_request *hreq; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1563 struct _bad_response_ctx *ctx; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1564 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1565 ctx = i_new(struct _bad_response_ctx, 1); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1566 ctx->count = 2; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1567 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1568 http_client = http_client_init(client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1569 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1570 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1571 "GET", net_ip2addr(&bind_ip), "/bad-response.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1572 test_client_bad_response_response, ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1573 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1574 http_client_request_submit(hreq); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1575 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1576 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1577 "GET", net_ip2addr(&bind_ip), "/bad-response2.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1578 test_client_bad_response_response, ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1579 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1580 http_client_request_submit(hreq); |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
1581 |
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
1582 return TRUE; |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1583 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1584 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1585 /* test */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1586 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1587 static void test_bad_response(void) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1588 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1589 struct http_client_settings http_client_set; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1590 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1591 test_client_defaults(&http_client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1592 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1593 test_begin("bad response"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1594 test_run_client_server(&http_client_set, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1595 test_client_bad_response, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1596 test_server_bad_response, 1, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1597 NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1598 test_end(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1599 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1600 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1601 /* |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1602 * Request timed out |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1603 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1604 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1605 /* server */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1606 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1607 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1608 test_request_timed_out_input(struct server_connection *conn ATTR_UNUSED) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1609 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1610 /* do nothing */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1611 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1612 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1613 static void test_server_request_timed_out(unsigned int index) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1614 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1615 test_server_input = test_request_timed_out_input; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1616 test_server_run(index); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1617 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1618 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1619 /* client */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1620 |
21856
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1621 struct _request_timed_out1_ctx { |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1622 unsigned int count; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1623 }; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1624 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1625 static void |
21856
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1626 test_client_request_timed_out1_response( |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1627 const struct http_response *resp, |
21856
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1628 struct _request_timed_out1_ctx *ctx) |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1629 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1630 if (debug) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1631 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1632 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1633 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_TIMED_OUT); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1634 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1635 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1636 if (--ctx->count == 0) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1637 i_free(ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1638 io_loop_stop(ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1639 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1640 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1641 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
1642 static bool |
21856
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1643 test_client_request_timed_out1(const struct http_client_settings *client_set) |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1644 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1645 struct http_client_request *hreq; |
21856
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1646 struct _request_timed_out1_ctx *ctx; |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1647 |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1648 ctx = i_new(struct _request_timed_out1_ctx, 1); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1649 ctx->count = 2; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1650 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1651 http_client = http_client_init(client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1652 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1653 hreq = http_client_request(http_client, |
21856
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1654 "GET", net_ip2addr(&bind_ip), "/request-timed-out1-1.txt", |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1655 test_client_request_timed_out1_response, ctx); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1656 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1657 http_client_request_submit(hreq); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1658 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1659 hreq = http_client_request(http_client, |
21856
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1660 "GET", net_ip2addr(&bind_ip), "/request-timed-out1-2.txt", |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1661 test_client_request_timed_out1_response, ctx); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1662 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1663 http_client_request_submit(hreq); |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
1664 |
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
1665 return TRUE; |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1666 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1667 |
21856
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1668 struct _request_timed_out2_ctx { |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1669 struct timeout *to; |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1670 unsigned int count; |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1671 unsigned int max_parallel_connections; |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1672 }; |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1673 |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1674 static void |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1675 test_client_request_timed_out2_timeout( |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1676 struct _request_timed_out2_ctx *ctx) |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1677 { |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1678 if (ctx->to != NULL) |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1679 timeout_remove(&ctx->to); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1680 i_debug("TIMEOUT"); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1681 } |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1682 |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1683 static void |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1684 test_client_request_timed_out2_response( |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1685 const struct http_response *resp, |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1686 struct _request_timed_out2_ctx *ctx) |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1687 { |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1688 if (debug) |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1689 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1690 |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1691 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_TIMED_OUT); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1692 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1693 test_assert(ctx->to != NULL); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1694 |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1695 if (--ctx->count > 0) { |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1696 if (ctx->to != NULL && ctx->max_parallel_connections <= 1) |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1697 timeout_reset(ctx->to); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1698 } else { |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1699 if (ctx->to != NULL) |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1700 timeout_remove(&ctx->to); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1701 i_free(ctx); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1702 io_loop_stop(ioloop); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1703 } |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1704 } |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1705 |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1706 static bool |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1707 test_client_request_timed_out2(const struct http_client_settings *client_set) |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1708 { |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1709 struct http_client_request *hreq; |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1710 struct _request_timed_out2_ctx *ctx; |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1711 |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1712 ctx = i_new(struct _request_timed_out2_ctx, 1); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1713 ctx->count = 2; |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1714 ctx->max_parallel_connections = |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1715 client_set->max_parallel_connections; |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1716 |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1717 ctx->to = timeout_add(2000, |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1718 test_client_request_timed_out2_timeout, ctx); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1719 |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1720 http_client = http_client_init(client_set); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1721 |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1722 hreq = http_client_request(http_client, |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1723 "GET", net_ip2addr(&bind_ip), "/request-timed-out2-1.txt", |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1724 test_client_request_timed_out2_response, ctx); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1725 http_client_request_set_port(hreq, bind_ports[0]); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1726 http_client_request_set_attempt_timeout_msecs(hreq, 1000); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1727 http_client_request_submit(hreq); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1728 |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1729 hreq = http_client_request(http_client, |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1730 "GET", net_ip2addr(&bind_ip), "/request-timed-out2-2.txt", |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1731 test_client_request_timed_out2_response, ctx); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1732 http_client_request_set_port(hreq, bind_ports[0]); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1733 http_client_request_set_attempt_timeout_msecs(hreq, 1000); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1734 http_client_request_submit(hreq); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1735 |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1736 return TRUE; |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1737 } |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1738 |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1739 /* test */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1740 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1741 static void test_request_timed_out(void) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1742 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1743 struct http_client_settings http_client_set; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1744 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1745 test_client_defaults(&http_client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1746 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1747 test_begin("request timed out: one attempt"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1748 http_client_set.request_timeout_msecs = 1000; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1749 http_client_set.max_attempts = 1; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1750 test_run_client_server(&http_client_set, |
21856
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1751 test_client_request_timed_out1, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1752 test_server_request_timed_out, 1, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1753 NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1754 test_end(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1755 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1756 test_begin("request timed out: two attempts"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1757 http_client_set.request_timeout_msecs = 1000; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1758 http_client_set.max_attempts = 1; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1759 test_run_client_server(&http_client_set, |
21856
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1760 test_client_request_timed_out1, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1761 test_server_request_timed_out, 1, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1762 NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1763 test_end(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1764 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1765 test_begin("request absolutely timed out"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1766 http_client_set.request_timeout_msecs = 0; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1767 http_client_set.request_absolute_timeout_msecs = 2000; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1768 http_client_set.max_attempts = 3; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1769 test_run_client_server(&http_client_set, |
21856
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1770 test_client_request_timed_out1, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1771 test_server_request_timed_out, 1, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1772 NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1773 test_end(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1774 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1775 test_begin("request double timed out"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1776 http_client_set.request_timeout_msecs = 500; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1777 http_client_set.request_absolute_timeout_msecs = 2000; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1778 http_client_set.max_attempts = 3; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1779 test_run_client_server(&http_client_set, |
21856
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1780 test_client_request_timed_out1, |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1781 test_server_request_timed_out, 1, |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1782 NULL); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1783 test_end(); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1784 |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1785 test_begin("request timed out: specific timeout"); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1786 http_client_set.request_timeout_msecs = 3000; |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1787 http_client_set.request_absolute_timeout_msecs = 0; |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1788 http_client_set.max_attempts = 1; |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1789 http_client_set.max_parallel_connections = 1; |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1790 test_run_client_server(&http_client_set, |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1791 test_client_request_timed_out2, |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1792 test_server_request_timed_out, 1, |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1793 NULL); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1794 test_end(); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1795 |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1796 test_begin("request timed out: specific timeout (parallel)"); |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1797 http_client_set.request_timeout_msecs = 3000; |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1798 http_client_set.request_absolute_timeout_msecs = 0; |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1799 http_client_set.max_attempts = 1; |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1800 http_client_set.max_parallel_connections = 4; |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1801 test_run_client_server(&http_client_set, |
a0112b13e73c
lib-http: client: Fixed request-specific attempt timeout.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21827
diff
changeset
|
1802 test_client_request_timed_out2, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1803 test_server_request_timed_out, 1, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1804 NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1805 test_end(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1806 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1807 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1808 /* |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1809 * Request aborted early |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1810 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1811 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1812 /* server */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1813 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1814 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1815 test_request_aborted_early_input(struct server_connection *conn ATTR_UNUSED) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1816 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1817 static const char *resp = |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1818 "HTTP/1.1 404 Not Found\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1819 "\r\n"; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1820 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1821 /* wait one second to respon */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1822 sleep(1); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1823 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1824 /* respond */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1825 o_stream_nsend_str(conn->conn.output, resp); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1826 server_connection_deinit(&conn); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1827 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1828 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1829 static void test_server_request_aborted_early(unsigned int index) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1830 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1831 test_server_input = test_request_aborted_early_input; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1832 test_server_run(index); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1833 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1834 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1835 /* client */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1836 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1837 struct _request_aborted_early_ctx { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1838 struct http_client_request *req1, *req2; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1839 struct timeout *to; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1840 }; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1841 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1842 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1843 test_client_request_aborted_early_response( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1844 const struct http_response *resp, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1845 struct _request_aborted_early_ctx *ctx ATTR_UNUSED) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1846 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1847 if (debug) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1848 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1849 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1850 /* abort does not trigger callback */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1851 test_assert(FALSE); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1852 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1853 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1854 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1855 test_client_request_aborted_early_timeout( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1856 struct _request_aborted_early_ctx *ctx) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1857 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1858 timeout_remove(&ctx->to); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1859 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1860 if (ctx->req1 != NULL) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1861 /* abort early */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1862 http_client_request_abort(&ctx->req1); /* sent */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1863 http_client_request_abort(&ctx->req2); /* only queued */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1864 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1865 /* wait a little for server to actually respond to an |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1866 already aborted request */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1867 ctx->to = timeout_add_short(1000, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1868 test_client_request_aborted_early_timeout, ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1869 } else { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1870 /* all done */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1871 i_free(ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1872 io_loop_stop(ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1873 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1874 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1875 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
1876 static bool |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1877 test_client_request_aborted_early( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1878 const struct http_client_settings *client_set) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1879 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1880 struct http_client_request *hreq; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1881 struct _request_aborted_early_ctx *ctx; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1882 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1883 ctx = i_new(struct _request_aborted_early_ctx, 1); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1884 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1885 http_client = http_client_init(client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1886 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1887 hreq = ctx->req1 = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1888 "GET", net_ip2addr(&bind_ip), "/request-aborted-early.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1889 test_client_request_aborted_early_response, ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1890 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1891 http_client_request_submit(hreq); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1892 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1893 hreq = ctx->req2 = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1894 "GET", net_ip2addr(&bind_ip), "/request-aborted-early2.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1895 test_client_request_aborted_early_response, ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1896 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1897 http_client_request_submit(hreq); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1898 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1899 ctx->to = timeout_add_short(500, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1900 test_client_request_aborted_early_timeout, ctx); |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
1901 return TRUE; |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1902 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1903 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1904 /* test */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1905 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1906 static void test_request_aborted_early(void) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1907 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1908 struct http_client_settings http_client_set; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1909 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1910 test_client_defaults(&http_client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1911 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1912 test_begin("request aborted early"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1913 test_run_client_server(&http_client_set, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1914 test_client_request_aborted_early, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1915 test_server_request_aborted_early, 1, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
1916 NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1917 test_end(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1918 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1919 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
1920 /* |
21053
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1921 * Request failed blocking |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1922 */ |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1923 |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1924 /* server */ |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1925 |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1926 static void |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1927 test_request_failed_blocking_input(struct server_connection *conn) |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1928 { |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1929 static const char *resp = |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1930 "HTTP/1.1 500 Internal Server Error\r\n" |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1931 "\r\n"; |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1932 |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1933 /* respond */ |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1934 o_stream_nsend_str(conn->conn.output, resp); |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1935 sleep(10); |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1936 server_connection_deinit(&conn); |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1937 } |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1938 |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1939 static void test_server_request_failed_blocking(unsigned int index) |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1940 { |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1941 test_server_input = test_request_failed_blocking_input; |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1942 test_server_run(index); |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1943 } |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1944 |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1945 /* client */ |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1946 |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1947 struct _request_failed_blocking_ctx { |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1948 struct http_client_request *req; |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1949 }; |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1950 |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1951 static void |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1952 test_client_request_failed_blocking_response( |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1953 const struct http_response *resp, |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1954 struct _request_failed_blocking_ctx *ctx ATTR_UNUSED) |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1955 { |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1956 if (debug) |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1957 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1958 |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1959 i_assert(resp->status == 500); |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1960 } |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1961 |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1962 static bool |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1963 test_client_request_failed_blocking( |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1964 const struct http_client_settings *client_set) |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1965 { |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1966 static const char *payload = "This a test payload!"; |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1967 struct http_client_request *hreq; |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1968 struct _request_failed_blocking_ctx *ctx; |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1969 unsigned int n; |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1970 string_t *data; |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1971 |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1972 data = str_new(default_pool, 1000000); |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1973 for (n = 0; n < 50000; n++) |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1974 str_append(data, payload); |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1975 |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1976 ctx = i_new(struct _request_failed_blocking_ctx, 1); |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1977 |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1978 http_client = http_client_init(client_set); |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1979 |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1980 hreq = ctx->req = http_client_request(http_client, |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1981 "GET", net_ip2addr(&bind_ip), "/request-failed-blocking.txt", |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1982 test_client_request_failed_blocking_response, ctx); |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1983 http_client_request_set_port(hreq, bind_ports[0]); |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1984 |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1985 test_assert(http_client_request_send_payload(&hreq, |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1986 str_data(data), str_len(data)) < 0); |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1987 i_assert(hreq == NULL); |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1988 |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1989 str_free(&data); |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1990 i_free(ctx); |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1991 return FALSE; |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1992 } |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1993 |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1994 /* test */ |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1995 |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1996 static void test_request_failed_blocking(void) |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1997 { |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1998 struct http_client_settings http_client_set; |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
1999 |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
2000 test_client_defaults(&http_client_set); |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
2001 http_client_set.socket_send_buffer_size = 4096; |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
2002 |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
2003 test_begin("request failed blocking"); |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
2004 test_run_client_server(&http_client_set, |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
2005 test_client_request_failed_blocking, |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
2006 test_server_request_failed_blocking, 1, |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
2007 NULL); |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
2008 test_end(); |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
2009 } |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
2010 |
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
2011 /* |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2012 * Client deinit early |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2013 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2014 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2015 /* server */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2016 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2017 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2018 test_client_deinit_early_input(struct server_connection *conn ATTR_UNUSED) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2019 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2020 static const char *resp = |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2021 "HTTP/1.1 404 Not Found\r\n" |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2022 "\r\n"; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2023 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2024 /* wait one second to respon */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2025 sleep(1); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2026 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2027 /* respond */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2028 o_stream_nsend_str(conn->conn.output, resp); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2029 server_connection_deinit(&conn); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2030 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2031 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2032 static void test_server_client_deinit_early(unsigned int index) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2033 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2034 test_server_input = test_client_deinit_early_input; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2035 test_server_run(index); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2036 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2037 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2038 /* client */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2039 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2040 struct _client_deinit_early_ctx { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2041 struct timeout *to; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2042 }; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2043 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2044 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2045 test_client_client_deinit_early_response( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2046 const struct http_response *resp, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2047 struct _client_deinit_early_ctx *ctx ATTR_UNUSED) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2048 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2049 if (debug) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2050 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2051 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2052 /* abort does not trigger callback */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2053 test_assert(FALSE); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2054 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2055 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2056 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2057 test_client_client_deinit_early_timeout( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2058 struct _client_deinit_early_ctx *ctx) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2059 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2060 timeout_remove(&ctx->to); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2061 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2062 /* deinit early */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2063 http_client_deinit(&http_client); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2064 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2065 /* all done */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2066 i_free(ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2067 io_loop_stop(ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2068 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2069 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
2070 static bool |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2071 test_client_client_deinit_early(const struct http_client_settings *client_set) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2072 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2073 struct http_client_request *hreq; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2074 struct _client_deinit_early_ctx *ctx; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2075 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2076 ctx = i_new(struct _client_deinit_early_ctx, 1); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2077 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2078 http_client = http_client_init(client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2079 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2080 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2081 "GET", net_ip2addr(&bind_ip), "/client-deinit-early.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2082 test_client_client_deinit_early_response, ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2083 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2084 http_client_request_submit(hreq); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2085 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2086 hreq = http_client_request(http_client, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2087 "GET", net_ip2addr(&bind_ip), "/client-deinit-early2.txt", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2088 test_client_client_deinit_early_response, ctx); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2089 http_client_request_set_port(hreq, bind_ports[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2090 http_client_request_submit(hreq); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2091 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2092 ctx->to = timeout_add_short(500, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2093 test_client_client_deinit_early_timeout, ctx); |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
2094 return TRUE; |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2095 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2096 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2097 /* test */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2098 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2099 static void test_client_deinit_early(void) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2100 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2101 struct http_client_settings http_client_set; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2102 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2103 test_client_defaults(&http_client_set); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2104 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2105 test_begin("client deinit early"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2106 test_run_client_server(&http_client_set, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2107 test_client_client_deinit_early, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2108 test_server_client_deinit_early, 1, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2109 NULL); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2110 test_end(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2111 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2112 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2113 /* |
20362
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2114 * Retry with delay |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2115 */ |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2116 |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2117 /* server */ |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2118 |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2119 static void |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2120 test_retry_with_delay_input(struct server_connection *conn) |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2121 { |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2122 string_t *resp; |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2123 |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2124 resp = t_str_new(512); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2125 str_printfa(resp, |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2126 "HTTP/1.1 500 Internal Server Error\r\n" |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2127 "\r\n"); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2128 o_stream_nsend(conn->conn.output, |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2129 str_data(resp), str_len(resp)); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2130 server_connection_deinit(&conn); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2131 } |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2132 |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2133 static void test_server_retry_with_delay(unsigned int index) |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2134 { |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2135 test_server_input = test_retry_with_delay_input; |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2136 test_server_run(index); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2137 } |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2138 |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2139 /* client */ |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2140 |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2141 struct _client_retry_with_delay_ctx { |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2142 struct http_client_request *req; |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2143 unsigned int retries; |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2144 struct timeval time; |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2145 }; |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2146 |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2147 static void |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2148 test_client_retry_with_delay_response( |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2149 const struct http_response *resp, |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2150 struct _client_retry_with_delay_ctx *ctx) |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2151 { |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2152 int real_delay, exp_delay; |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2153 |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2154 if (debug) |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2155 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2156 |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2157 test_assert(resp->status == 500); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2158 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2159 |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2160 if (ctx->retries > 0) { |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2161 /* check delay */ |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2162 real_delay = timeval_diff_msecs(&ioloop_timeval, &ctx->time); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2163 exp_delay = (1 << (ctx->retries-1)) * 50; |
21026
5a0044accf49
lib-http: Made test-http-client-errors more reliable.
Stephan Bosch <stephan@dovecot.fi>
parents:
20365
diff
changeset
|
2164 if (real_delay < exp_delay-2) { |
20362
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2165 i_fatal("Retry delay is too short %d < %d", |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2166 real_delay, exp_delay); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2167 } |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2168 } |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2169 |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2170 http_client_request_delay_msecs(ctx->req, (1 << ctx->retries) * 50); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2171 ctx->time = ioloop_timeval; |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2172 if (http_client_request_try_retry(ctx->req)) { |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2173 ctx->retries++; |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2174 if (debug) |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2175 i_debug("retrying"); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2176 return; |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2177 } |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2178 |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2179 i_free(ctx); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2180 io_loop_stop(ioloop); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2181 } |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2182 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
2183 static bool |
20362
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2184 test_client_retry_with_delay(const struct http_client_settings *client_set) |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2185 { |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2186 struct http_client_request *hreq; |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2187 struct _client_retry_with_delay_ctx *ctx; |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2188 |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2189 ctx = i_new(struct _client_retry_with_delay_ctx, 1); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2190 ctx->time = ioloop_timeval; |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2191 |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2192 http_client = http_client_init(client_set); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2193 |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2194 ctx->req = hreq = http_client_request(http_client, |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2195 "GET", net_ip2addr(&bind_ip), "/retry-with-delay.txt", |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2196 test_client_retry_with_delay_response, ctx); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2197 http_client_request_set_port(hreq, bind_ports[0]); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2198 http_client_request_submit(hreq); |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
2199 |
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
2200 return TRUE; |
20362
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2201 } |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2202 |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2203 /* test */ |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2204 |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2205 static void test_retry_with_delay(void) |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2206 { |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2207 struct http_client_settings http_client_set; |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2208 |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2209 test_client_defaults(&http_client_set); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2210 http_client_set.max_attempts = 3; |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2211 |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2212 test_begin("retry with delay"); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2213 test_run_client_server(&http_client_set, |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2214 test_client_retry_with_delay, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2215 test_server_retry_with_delay, 1, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2216 NULL); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2217 test_end(); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2218 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2219 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2220 /* |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2221 * DNS service failure |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2222 */ |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2223 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2224 /* client */ |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2225 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2226 struct _dns_service_failure { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2227 unsigned int count; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2228 }; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2229 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2230 static void |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2231 test_client_dns_service_failure_response( |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2232 const struct http_response *resp, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2233 struct _dns_service_failure *ctx) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2234 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2235 if (debug) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2236 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2237 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2238 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_HOST_LOOKUP_FAILED); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2239 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2240 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2241 if (--ctx->count == 0) { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2242 i_free(ctx); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2243 io_loop_stop(ioloop); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2244 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2245 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2246 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
2247 static bool |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2248 test_client_dns_service_failure(const struct http_client_settings *client_set) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2249 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2250 struct http_client_request *hreq; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2251 struct _dns_service_failure *ctx; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2252 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2253 ctx = i_new(struct _dns_service_failure, 1); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2254 ctx->count = 2; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2255 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2256 http_client = http_client_init(client_set); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2257 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2258 hreq = http_client_request(http_client, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2259 "GET", "example.com", "/dns-service-failure.txt", |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2260 test_client_dns_service_failure_response, ctx); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2261 http_client_request_set_port(hreq, 80); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2262 http_client_request_submit(hreq); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2263 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2264 hreq = http_client_request(http_client, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2265 "GET", "example.com", "/dns-service-failure2.txt", |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2266 test_client_dns_service_failure_response, ctx); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2267 http_client_request_set_port(hreq, 80); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2268 http_client_request_submit(hreq); |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
2269 |
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
2270 return TRUE; |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2271 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2272 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2273 /* test */ |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2274 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2275 static void test_dns_service_failure(void) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2276 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2277 struct http_client_settings http_client_set; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2278 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2279 test_client_defaults(&http_client_set); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2280 http_client_set.dns_client_socket_path = "./frop"; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2281 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2282 test_begin("dns service failure"); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2283 test_run_client_server(&http_client_set, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2284 test_client_dns_service_failure, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2285 NULL, 0, NULL); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2286 test_end(); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2287 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2288 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2289 /* |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2290 * DNS timeout |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2291 */ |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2292 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2293 /* dns */ |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2294 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2295 static void |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2296 test_dns_timeout_input(struct server_connection *conn ATTR_UNUSED) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2297 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2298 /* hang */ |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2299 sleep(100); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2300 server_connection_deinit(&conn); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2301 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2302 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2303 static void test_dns_dns_timeout(void) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2304 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2305 test_server_input = test_dns_timeout_input; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2306 test_server_run(0); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2307 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2308 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2309 /* client */ |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2310 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2311 struct _dns_timeout { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2312 unsigned int count; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2313 }; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2314 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2315 static void |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2316 test_client_dns_timeout_response( |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2317 const struct http_response *resp, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2318 struct _dns_timeout *ctx) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2319 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2320 if (debug) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2321 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2322 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2323 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_HOST_LOOKUP_FAILED); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2324 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2325 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2326 if (--ctx->count == 0) { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2327 i_free(ctx); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2328 io_loop_stop(ioloop); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2329 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2330 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2331 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
2332 static bool |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2333 test_client_dns_timeout(const struct http_client_settings *client_set) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2334 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2335 struct http_client_request *hreq; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2336 struct _dns_timeout *ctx; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2337 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2338 ctx = i_new(struct _dns_timeout, 1); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2339 ctx->count = 2; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2340 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2341 http_client = http_client_init(client_set); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2342 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2343 hreq = http_client_request(http_client, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2344 "GET", "example.com", "/dns-timeout.txt", |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2345 test_client_dns_timeout_response, ctx); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2346 http_client_request_set_port(hreq, 80); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2347 http_client_request_submit(hreq); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2348 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2349 hreq = http_client_request(http_client, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2350 "GET", "example.com", "/dns-timeout2.txt", |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2351 test_client_dns_timeout_response, ctx); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2352 http_client_request_set_port(hreq, 80); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2353 http_client_request_submit(hreq); |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
2354 |
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
2355 return TRUE; |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2356 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2357 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2358 /* test */ |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2359 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2360 static void test_dns_timeout(void) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2361 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2362 struct http_client_settings http_client_set; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2363 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2364 test_client_defaults(&http_client_set); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2365 http_client_set.request_timeout_msecs = 2000; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2366 http_client_set.connect_timeout_msecs = 2000; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2367 http_client_set.dns_client_socket_path = "./dns-test"; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2368 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2369 test_begin("dns timeout"); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2370 test_run_client_server(&http_client_set, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2371 test_client_dns_timeout, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2372 NULL, 0, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2373 test_dns_dns_timeout); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2374 test_end(); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2375 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2376 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2377 /* |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2378 * DNS lookup failure |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2379 */ |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2380 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2381 /* dns */ |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2382 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2383 static void |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2384 test_dns_lookup_failure_input(struct server_connection *conn) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2385 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2386 o_stream_nsend_str(conn->conn.output, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2387 t_strdup_printf("%d\n", EAI_FAIL)); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2388 server_connection_deinit(&conn); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2389 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2390 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2391 static void test_dns_dns_lookup_failure(void) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2392 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2393 test_server_input = test_dns_lookup_failure_input; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2394 test_server_run(0); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2395 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2396 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2397 /* client */ |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2398 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2399 struct _dns_lookup_failure { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2400 unsigned int count; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2401 }; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2402 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2403 static void |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2404 test_client_dns_lookup_failure_response( |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2405 const struct http_response *resp, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2406 struct _dns_lookup_failure *ctx) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2407 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2408 if (debug) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2409 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2410 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2411 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_HOST_LOOKUP_FAILED); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2412 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2413 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2414 if (--ctx->count == 0) { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2415 i_free(ctx); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2416 io_loop_stop(ioloop); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2417 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2418 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2419 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
2420 static bool |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2421 test_client_dns_lookup_failure(const struct http_client_settings *client_set) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2422 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2423 struct http_client_request *hreq; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2424 struct _dns_lookup_failure *ctx; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2425 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2426 ctx = i_new(struct _dns_lookup_failure, 1); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2427 ctx->count = 2; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2428 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2429 http_client = http_client_init(client_set); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2430 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2431 hreq = http_client_request(http_client, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2432 "GET", "example.com", "/dns-lookup-failure.txt", |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2433 test_client_dns_lookup_failure_response, ctx); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2434 http_client_request_set_port(hreq, 80); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2435 http_client_request_submit(hreq); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2436 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2437 hreq = http_client_request(http_client, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2438 "GET", "example.com", "/dns-lookup-failure2.txt", |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2439 test_client_dns_lookup_failure_response, ctx); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2440 http_client_request_set_port(hreq, 80); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2441 http_client_request_submit(hreq); |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
2442 |
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
2443 return TRUE; |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2444 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2445 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2446 /* test */ |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2447 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2448 static void test_dns_lookup_failure(void) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2449 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2450 struct http_client_settings http_client_set; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2451 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2452 test_client_defaults(&http_client_set); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2453 http_client_set.dns_client_socket_path = "./dns-test"; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2454 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2455 test_begin("dns lookup failure"); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2456 test_run_client_server(&http_client_set, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2457 test_client_dns_lookup_failure, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2458 NULL, 0, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2459 test_dns_dns_lookup_failure); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2460 test_end(); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2461 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2462 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2463 /* |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2464 * DNS lookup ttl |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2465 */ |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2466 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2467 /* dns */ |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2468 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2469 static void |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2470 test_dns_lookup_ttl_input(struct server_connection *conn) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2471 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2472 static unsigned int count = 0; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2473 const char *line; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2474 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2475 while ((line=i_stream_read_next_line(conn->conn.input)) != NULL) { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2476 if (debug) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2477 i_debug("DNS REQUEST %u: %s", count, line); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2478 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2479 if (count == 0) { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2480 o_stream_nsend_str(conn->conn.output, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2481 "0 1\n127.0.0.1\n"); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2482 } else { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2483 o_stream_nsend_str(conn->conn.output, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2484 t_strdup_printf("%d\n", EAI_FAIL)); |
21050
461e5847c268
lib-http: Fixed potential segfault problem in test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21049
diff
changeset
|
2485 if (count > 4) { |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2486 server_connection_deinit(&conn); |
21050
461e5847c268
lib-http: Fixed potential segfault problem in test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21049
diff
changeset
|
2487 return; |
461e5847c268
lib-http: Fixed potential segfault problem in test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21049
diff
changeset
|
2488 } |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2489 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2490 count++; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2491 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2492 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2493 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2494 static void test_dns_dns_lookup_ttl(void) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2495 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2496 test_server_input = test_dns_lookup_ttl_input; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2497 test_server_run(0); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2498 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2499 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2500 /* server */ |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2501 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2502 static void |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2503 test_server_dns_lookup_ttl_input(struct server_connection *conn) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2504 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2505 string_t *resp; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2506 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2507 resp = t_str_new(512); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2508 str_printfa(resp, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2509 "HTTP/1.1 200 OK\r\n" |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2510 "Connection: close\r\n" |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2511 "\r\n"); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2512 o_stream_nsend(conn->conn.output, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2513 str_data(resp), str_len(resp)); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2514 server_connection_deinit(&conn); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2515 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2516 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2517 static void test_server_dns_lookup_ttl(unsigned int index) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2518 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2519 test_server_input = test_server_dns_lookup_ttl_input; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2520 test_server_run(index); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2521 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2522 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2523 /* client */ |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2524 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2525 struct _dns_lookup_ttl { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2526 struct http_client *client; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2527 unsigned int count; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2528 struct timeout *to; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2529 }; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2530 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2531 static void |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2532 test_client_dns_lookup_ttl_response_stage2( |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2533 const struct http_response *resp, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2534 struct _dns_lookup_ttl *ctx) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2535 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2536 if (debug) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2537 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2538 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2539 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_HOST_LOOKUP_FAILED); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2540 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2541 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2542 if (--ctx->count == 0) { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2543 i_free(ctx); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2544 io_loop_stop(ioloop); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2545 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2546 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2547 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2548 static void |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2549 test_client_dns_lookup_ttl_stage2_start(struct _dns_lookup_ttl *ctx) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2550 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2551 struct http_client_request *hreq; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2552 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2553 timeout_remove(&ctx->to); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2554 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2555 ctx->count = 2; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2556 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2557 hreq = http_client_request(ctx->client, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2558 "GET", "example.com", "/dns-lookup-ttl-stage2.txt", |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2559 test_client_dns_lookup_ttl_response_stage2, ctx); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2560 http_client_request_set_port(hreq, bind_ports[0]); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2561 http_client_request_submit(hreq); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2562 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2563 hreq = http_client_request(ctx->client, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2564 "GET", "example.com", "/dns-lookup-ttl2-stage2.txt", |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2565 test_client_dns_lookup_ttl_response_stage2, ctx); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2566 http_client_request_set_port(hreq, bind_ports[0]); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2567 http_client_request_submit(hreq); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2568 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2569 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2570 static void |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2571 test_client_dns_lookup_ttl_response_stage1( |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2572 const struct http_response *resp, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2573 struct _dns_lookup_ttl *ctx) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2574 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2575 if (debug) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2576 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2577 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2578 test_assert(resp->status == 200); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2579 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2580 if (--ctx->count == 0) { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2581 ctx->to = timeout_add(2000, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2582 test_client_dns_lookup_ttl_stage2_start, ctx); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2583 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2584 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2585 |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
2586 static bool |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2587 test_client_dns_lookup_ttl(const struct http_client_settings *client_set) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2588 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2589 struct http_client_request *hreq; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2590 struct _dns_lookup_ttl *ctx; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2591 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2592 ctx = i_new(struct _dns_lookup_ttl, 1); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2593 ctx->count = 2; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2594 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2595 ctx->client = http_client = http_client_init(client_set); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2596 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2597 hreq = http_client_request(ctx->client, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2598 "GET", "example.com", "/dns-lookup-ttl-stage1.txt", |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2599 test_client_dns_lookup_ttl_response_stage1, ctx); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2600 http_client_request_set_port(hreq, bind_ports[0]); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2601 http_client_request_submit(hreq); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2602 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2603 hreq = http_client_request(ctx->client, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2604 "GET", "example.com", "/dns-lookup-ttl2-stage1.txt", |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2605 test_client_dns_lookup_ttl_response_stage1, ctx); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2606 http_client_request_set_port(hreq, bind_ports[0]); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2607 http_client_request_submit(hreq); |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
2608 |
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
2609 return TRUE; |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2610 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2611 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2612 /* test */ |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2613 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2614 static void test_dns_lookup_ttl(void) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2615 { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2616 struct http_client_settings http_client_set; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2617 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2618 test_client_defaults(&http_client_set); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2619 http_client_set.dns_client_socket_path = "./dns-test"; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2620 http_client_set.dns_ttl_msecs = 1000; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2621 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2622 test_begin("dns lookup ttl"); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2623 test_run_client_server(&http_client_set, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2624 test_client_dns_lookup_ttl, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2625 test_server_dns_lookup_ttl, 1, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2626 test_dns_dns_lookup_ttl); |
20362
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2627 test_end(); |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2628 } |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2629 |
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2630 /* |
21263
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2631 * Peer reuse failure |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2632 */ |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2633 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2634 /* server */ |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2635 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2636 static void |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2637 test_peer_reuse_failure_input(struct server_connection *conn) |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2638 { |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2639 static unsigned int seq = 0; |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2640 static const char *resp = |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2641 "HTTP/1.1 200 OK\r\n" |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2642 "\r\n"; |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2643 o_stream_nsend_str(conn->conn.output, resp); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2644 if (seq++ > 2) { |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2645 server_connection_deinit(&conn); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2646 io_loop_stop(current_ioloop); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2647 } |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2648 } |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2649 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2650 static void test_server_peer_reuse_failure(unsigned int index) |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2651 { |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2652 test_server_input = test_peer_reuse_failure_input; |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2653 test_server_run(index); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2654 } |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2655 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2656 /* client */ |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2657 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2658 struct _peer_reuse_failure { |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2659 struct timeout *to; |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2660 bool first:1; |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2661 }; |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2662 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2663 static void |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2664 test_client_peer_reuse_failure_response2( |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2665 const struct http_response *resp, |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2666 struct _peer_reuse_failure *ctx) |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2667 { |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2668 if (debug) |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2669 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2670 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2671 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_CONNECT_FAILED); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2672 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2673 i_free(ctx); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2674 io_loop_stop(ioloop); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2675 } |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2676 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2677 static void |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2678 test_client_peer_reuse_failure_next(struct _peer_reuse_failure *ctx) |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2679 { |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2680 struct http_client_request *hreq; |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2681 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2682 timeout_remove(&ctx->to); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2683 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2684 hreq = http_client_request(http_client, |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2685 "GET", net_ip2addr(&bind_ip), "/peer-reuse-next.txt", |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2686 test_client_peer_reuse_failure_response2, ctx); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2687 http_client_request_set_port(hreq, bind_ports[0]); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2688 http_client_request_submit(hreq); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2689 } |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2690 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2691 static void |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2692 test_client_peer_reuse_failure_response1( |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2693 const struct http_response *resp, |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2694 struct _peer_reuse_failure *ctx) |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2695 { |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2696 if (debug) |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2697 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2698 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2699 if (ctx->first) { |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2700 test_assert(resp->status == 200); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2701 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2702 ctx->first = FALSE; |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2703 ctx->to = timeout_add_short(500, test_client_peer_reuse_failure_next, ctx); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2704 } else { |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2705 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_CONNECT_FAILED); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2706 } |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2707 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2708 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2709 } |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2710 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2711 static bool |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2712 test_client_peer_reuse_failure(const struct http_client_settings *client_set) |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2713 { |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2714 struct http_client_request *hreq; |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2715 struct _peer_reuse_failure *ctx; |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2716 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2717 ctx = i_new(struct _peer_reuse_failure, 1); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2718 ctx->first = TRUE; |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2719 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2720 http_client = http_client_init(client_set); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2721 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2722 hreq = http_client_request(http_client, |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2723 "GET", net_ip2addr(&bind_ip), "/peer-reuse.txt", |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2724 test_client_peer_reuse_failure_response1, ctx); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2725 http_client_request_set_port(hreq, bind_ports[0]); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2726 http_client_request_submit(hreq); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2727 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2728 hreq = http_client_request(http_client, |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2729 "GET", net_ip2addr(&bind_ip), "/peer-reuse.txt", |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2730 test_client_peer_reuse_failure_response1, ctx); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2731 http_client_request_set_port(hreq, bind_ports[0]); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2732 http_client_request_submit(hreq); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2733 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2734 hreq = http_client_request(http_client, |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2735 "GET", net_ip2addr(&bind_ip), "/peer-reuse.txt", |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2736 test_client_peer_reuse_failure_response1, ctx); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2737 http_client_request_set_port(hreq, bind_ports[0]); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2738 http_client_request_submit(hreq); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2739 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2740 return TRUE; |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2741 } |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2742 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2743 /* test */ |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2744 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2745 static void test_peer_reuse_failure(void) |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2746 { |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2747 struct http_client_settings http_client_set; |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2748 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2749 test_client_defaults(&http_client_set); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2750 http_client_set.max_connect_attempts = 1; |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2751 http_client_set.max_idle_time_msecs = 500; |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2752 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2753 test_begin("peer reuse failure"); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2754 test_run_client_server(&http_client_set, |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2755 test_client_peer_reuse_failure, |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2756 test_server_peer_reuse_failure, 1, |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2757 NULL); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2758 test_end(); |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2759 } |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2760 |
21466
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2761 /* |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2762 * Reconnect failure |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2763 */ |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2764 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2765 /* dns */ |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2766 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2767 static void |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2768 test_dns_reconnect_failure_input(struct server_connection *conn) |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2769 { |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2770 static unsigned int count = 0; |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2771 const char *line; |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2772 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2773 while ((line=i_stream_read_next_line(conn->conn.input)) != NULL) { |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2774 if (debug) |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2775 i_debug("DNS REQUEST %u: %s", count, line); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2776 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2777 if (count == 0) { |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2778 o_stream_nsend_str(conn->conn.output, |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2779 "0 1\n127.0.0.1\n"); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2780 } else { |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2781 o_stream_nsend_str(conn->conn.output, |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2782 t_strdup_printf("%d\n", EAI_FAIL)); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2783 if (count > 4) { |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2784 server_connection_deinit(&conn); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2785 return; |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2786 } |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2787 } |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2788 count++; |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2789 } |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2790 } |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2791 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2792 static void test_dns_reconnect_failure(void) |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2793 { |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2794 test_server_input = test_dns_reconnect_failure_input; |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2795 test_server_run(0); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2796 } |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2797 /* server */ |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2798 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2799 static void |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2800 test_reconnect_failure_input(struct server_connection *conn) |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2801 { |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2802 static const char *resp = |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2803 "HTTP/1.1 200 OK\r\n" |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2804 "Content-Length: 18\r\n" |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2805 "\r\n" |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2806 "Everything is OK\r\n"; |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2807 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2808 o_stream_nsend_str(conn->conn.output, resp); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2809 i_close_fd(&fd_listen); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2810 sleep(500); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2811 } |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2812 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2813 static void test_server_reconnect_failure(unsigned int index) |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2814 { |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2815 test_server_input = test_reconnect_failure_input; |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2816 test_server_run(index); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2817 } |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2818 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2819 /* client */ |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2820 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2821 struct _reconnect_failure_ctx { |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2822 struct timeout *to; |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2823 }; |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2824 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2825 static void |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2826 test_client_reconnect_failure_response2( |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2827 const struct http_response *resp, |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2828 struct _reconnect_failure_ctx *ctx) |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2829 { |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2830 if (debug) |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2831 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2832 |
21785
22764c03b37c
lib-http: test-http-client-errors: Always use the proper error status code definitions rather than an integer literal.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21466
diff
changeset
|
2833 test_assert(resp->status == HTTP_CLIENT_REQUEST_ERROR_CONNECT_FAILED); |
21466
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2834 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2835 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2836 io_loop_stop(ioloop); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2837 i_free(ctx); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2838 } |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2839 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2840 static void |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2841 test_client_reconnect_failure_next( |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2842 struct _reconnect_failure_ctx *ctx) |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2843 { |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2844 struct http_client_request *hreq; |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2845 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2846 if (debug) |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2847 i_debug("NEXT REQUEST"); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2848 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2849 timeout_remove(&ctx->to); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2850 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2851 hreq = http_client_request(http_client, |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2852 "GET", "example.com", "/reconnect-failure-2.txt", |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2853 test_client_reconnect_failure_response2, ctx); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2854 http_client_request_set_port(hreq, bind_ports[0]); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2855 http_client_request_submit(hreq); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2856 } |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2857 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2858 static void |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2859 test_client_reconnect_failure_response1( |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2860 const struct http_response *resp, |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2861 struct _reconnect_failure_ctx *ctx) |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2862 { |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2863 if (debug) |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2864 i_debug("RESPONSE: %u %s", resp->status, resp->reason); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2865 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2866 test_assert(resp->status == 200); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2867 test_assert(resp->reason != NULL && *resp->reason != '\0'); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2868 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2869 ctx->to = timeout_add_short(999, |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2870 test_client_reconnect_failure_next, ctx); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2871 } |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2872 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2873 static bool |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2874 test_client_reconnect_failure(const struct http_client_settings *client_set) |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2875 { |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2876 struct http_client_request *hreq; |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2877 struct _reconnect_failure_ctx *ctx; |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2878 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2879 ctx = i_new(struct _reconnect_failure_ctx, 1); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2880 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2881 http_client = http_client_init(client_set); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2882 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2883 hreq = http_client_request(http_client, |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2884 "GET", "example.com", "/reconnect-failure-1.txt", |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2885 test_client_reconnect_failure_response1, ctx); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2886 http_client_request_set_port(hreq, bind_ports[0]); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2887 http_client_request_submit(hreq); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2888 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2889 return TRUE; |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2890 } |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2891 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2892 /* test */ |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2893 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2894 static void test_reconnect_failure(void) |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2895 { |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2896 struct http_client_settings http_client_set; |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2897 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2898 test_client_defaults(&http_client_set); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2899 http_client_set.dns_client_socket_path = "./dns-test"; |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2900 http_client_set.dns_ttl_msecs = 2000; |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2901 http_client_set.max_idle_time_msecs = 1000; |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2902 http_client_set.max_attempts = 1; |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2903 http_client_set.request_timeout_msecs = 1000; |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2904 |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2905 test_begin("reconnect failure"); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2906 test_run_client_server(&http_client_set, |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2907 test_client_reconnect_failure, |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2908 test_server_reconnect_failure, 1, |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2909 test_dns_reconnect_failure); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2910 test_end(); |
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2911 } |
21263
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2912 |
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2913 /* |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2914 * All tests |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2915 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2916 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2917 static void (*test_functions[])(void) = { |
21789
71d43e069358
lib-http: test-http-client-errors: Added test for using https:// while SSL is not configured.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21785
diff
changeset
|
2918 test_unconfigured_ssl, |
21827
f72bff071414
lib-http: client: Fix aborting a request that has a delayed error.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21793
diff
changeset
|
2919 test_unconfigured_ssl_abort, |
21793
e3b32123b0c2
lib-http: client: Implemented http_client_request_url_str() function that accepts an URL string rather than a pre-parsed URL object.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21789
diff
changeset
|
2920 test_invalid_url, |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2921 test_host_lookup_failed, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2922 test_connection_refused, |
21336
fdb33b075caa
lib-http: client: Added test for premature connection loss to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21335
diff
changeset
|
2923 test_connection_lost_prematurely, |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2924 test_connection_timed_out, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2925 test_invalid_redirect, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2926 test_unseekable_redirect, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2927 test_unseekable_retry, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2928 test_broken_payload, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2929 test_connection_lost, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2930 test_connection_lost_100, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2931 test_connection_lost_sub_ioloop, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2932 test_early_success, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2933 test_bad_response, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2934 test_request_timed_out, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2935 test_request_aborted_early, |
21053
b0ef5af74fb5
lib-http: test-http-client-errors: Add test for server that returns error status early while client is still sending blocking payload.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21051
diff
changeset
|
2936 test_request_failed_blocking, |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2937 test_client_deinit_early, |
20362
7726ef50ccff
lib-http: client: Added test for http_client_request_delay_msecs() in test_http_client_errors.
Stephan Bosch <stephan@dovecot.fi>
parents:
20360
diff
changeset
|
2938 test_retry_with_delay, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2939 test_dns_service_failure, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2940 test_dns_timeout, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2941 test_dns_lookup_failure, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
2942 test_dns_lookup_ttl, |
21263
1c92017ddd88
lib-http: client: Fixed assert failure occurring when a new connection fails for a peer that has active connections.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21053
diff
changeset
|
2943 test_peer_reuse_failure, |
21466
10103d3a4ad4
lib-http: client: Fixed peer reconnection failure handling.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21390
diff
changeset
|
2944 test_reconnect_failure, |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2945 NULL |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2946 }; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2947 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2948 /* |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2949 * Test client |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2950 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2951 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2952 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2953 test_client_defaults(struct http_client_settings *http_set) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2954 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2955 /* client settings */ |
21389
59437f8764c6
global: Replaced all instances of memset(p, 0, sizeof(*p)) with the new i_zero() macro.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21336
diff
changeset
|
2956 i_zero(http_set); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2957 http_set->max_idle_time_msecs = 5*1000; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2958 http_set->max_parallel_connections = 1; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2959 http_set->max_pipelined_requests = 1; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2960 http_set->max_redirects = 0; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2961 http_set->max_attempts = 1; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2962 http_set->debug = debug; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2963 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2964 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2965 static void test_client_deinit(void) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2966 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2967 if (http_client != NULL) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2968 http_client_deinit(&http_client); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2969 http_client = NULL; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2970 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2971 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2972 /* |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2973 * Test server |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2974 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2975 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2976 /* client connection */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2977 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2978 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2979 server_connection_input(struct connection *_conn) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2980 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2981 struct server_connection *conn = (struct server_connection *)_conn; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2982 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2983 test_server_input(conn); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2984 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2985 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2986 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2987 server_connection_init(int fd) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2988 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2989 struct server_connection *conn; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2990 pool_t pool; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2991 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2992 net_set_nonblock(fd, TRUE); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2993 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2994 pool = pool_alloconly_create("server connection", 256); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2995 conn = p_new(pool, struct server_connection, 1); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2996 conn->pool = pool; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2997 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2998 connection_init_server |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
2999 (server_conn_list, &conn->conn, "server connection", fd, fd); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3000 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3001 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3002 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3003 server_connection_deinit(struct server_connection **_conn) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3004 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3005 struct server_connection *conn = *_conn; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3006 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3007 *_conn = NULL; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3008 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3009 connection_deinit(&conn->conn); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3010 pool_unref(&conn->pool); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3011 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3012 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3013 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3014 server_connection_destroy(struct connection *_conn) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3015 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3016 struct server_connection *conn = |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3017 (struct server_connection *)_conn; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3018 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3019 server_connection_deinit(&conn); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3020 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3021 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3022 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3023 server_connection_accept(void *context ATTR_UNUSED) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3024 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3025 int fd; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3026 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3027 /* accept new client */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3028 fd = net_accept(fd_listen, NULL, NULL); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3029 if (fd == -1) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3030 return; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3031 if (fd == -2) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3032 i_fatal("test server: accept() failed: %m"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3033 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3034 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3035 server_connection_init(fd); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3036 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3037 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3038 /* */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3039 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3040 static struct connection_settings server_connection_set = { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3041 .input_max_size = (size_t)-1, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3042 .output_max_size = (size_t)-1, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3043 .client = FALSE |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3044 }; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3045 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3046 static const struct connection_vfuncs server_connection_vfuncs = { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3047 .destroy = server_connection_destroy, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3048 .input = server_connection_input |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3049 }; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3050 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3051 static void test_server_run(unsigned int index) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3052 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3053 server_index = index; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3054 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3055 /* open server socket */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3056 io_listen = io_add(fd_listen, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3057 IO_READ, server_connection_accept, (void *)NULL); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3058 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3059 server_conn_list = connection_list_init |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3060 (&server_connection_set, &server_connection_vfuncs); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3061 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3062 io_loop_run(ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3063 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3064 /* close server socket */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3065 io_remove(&io_listen); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3066 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3067 connection_list_deinit(&server_conn_list); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3068 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3069 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3070 /* |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3071 * Tests |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3072 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3073 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3074 static int test_open_server_fd(in_port_t *bind_port) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3075 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3076 int fd = net_listen(&bind_ip, bind_port, 128); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3077 if (debug) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3078 i_debug("server listening on %u", *bind_port); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3079 if (fd == -1) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3080 i_fatal("listen(%s:%u) failed: %m", |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3081 net_ip2addr(&bind_ip), *bind_port); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3082 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3083 return fd; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3084 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3085 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3086 static void test_servers_kill_all(void) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3087 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3088 unsigned int i; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3089 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3090 if (server_pids_count > 0) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3091 for (i = 0; i < server_pids_count; i++) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3092 if (server_pids[i] != (pid_t)-1) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3093 (void)kill(server_pids[i], SIGKILL); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3094 (void)waitpid(server_pids[i], NULL, 0); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3095 server_pids[i] = -1; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3096 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3097 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3098 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3099 server_pids_count = 0; |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3100 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3101 if (dns_pid != (pid_t)-1) { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3102 (void)kill(dns_pid, SIGKILL); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3103 (void)waitpid(dns_pid, NULL, 0); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3104 dns_pid = (pid_t)-1; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3105 } |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3106 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3107 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3108 static void test_run_client_server( |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3109 const struct http_client_settings *client_set, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3110 test_client_init_t client_test, |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3111 test_server_init_t server_test, |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3112 unsigned int server_tests_count, |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3113 test_dns_init_t dns_test) |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3114 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3115 unsigned int i; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3116 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3117 server_pids = NULL; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3118 server_pids_count = 0; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3119 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3120 if (server_tests_count > 0) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3121 int fds[server_tests_count]; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3122 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3123 bind_ports = i_new(in_port_t, server_tests_count); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3124 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3125 server_pids = i_new(pid_t, server_tests_count); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3126 for (i = 0; i < server_tests_count; i++) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3127 server_pids[i] = (pid_t)-1; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3128 server_pids_count = server_tests_count; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3129 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3130 for (i = 0; i < server_tests_count; i++) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3131 fds[i] = test_open_server_fd(&bind_ports[i]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3132 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3133 for (i = 0; i < server_tests_count; i++) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3134 fd_listen = fds[i]; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3135 if ((server_pids[i] = fork()) == (pid_t)-1) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3136 i_fatal("fork() failed: %m"); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3137 if (server_pids[i] == 0) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3138 server_pids[i] = (pid_t)-1; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3139 server_pids_count = 0; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3140 hostpid_init(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3141 if (debug) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3142 i_debug("server[%d]: PID=%s", i+1, my_pid); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3143 /* child: server */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3144 ioloop = io_loop_create(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3145 server_test(i); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3146 io_loop_destroy(&ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3147 if (fd_listen != -1) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3148 i_close_fd(&fd_listen); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3149 i_free(bind_ports); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3150 i_free(server_pids); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3151 /* wait for it to be killed; this way, valgrind will not |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3152 object to this process going away inelegantly. */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3153 sleep(60); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3154 exit(1); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3155 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3156 if (fd_listen != -1) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3157 i_close_fd(&fd_listen); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3158 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3159 if (debug) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3160 i_debug("client: PID=%s", my_pid); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3161 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3162 |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3163 if (dns_test != NULL) { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3164 int fd; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3165 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3166 i_unlink_if_exists("./dns-test"); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3167 fd = net_listen_unix("./dns-test", 128); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3168 if (fd == -1) { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3169 i_fatal("listen(./dns-test) failed: %m"); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3170 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3171 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3172 fd_listen = fd; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3173 if ((dns_pid = fork()) == (pid_t)-1) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3174 i_fatal("fork() failed: %m"); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3175 if (dns_pid == 0) { |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3176 dns_pid = (pid_t)-1; |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3177 hostpid_init(); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3178 if (debug) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3179 i_debug("dns server: PID=%s", my_pid); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3180 /* child: server */ |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3181 ioloop = io_loop_create(); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3182 dns_test(); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3183 io_loop_destroy(&ioloop); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3184 if (fd_listen != -1) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3185 i_close_fd(&fd_listen); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3186 /* wait for it to be killed; this way, valgrind will not |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3187 object to this process going away inelegantly. */ |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3188 sleep(60); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3189 exit(1); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3190 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3191 if (fd_listen != -1) |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3192 i_close_fd(&fd_listen); |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3193 } |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3194 |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3195 /* parent: client */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3196 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3197 usleep(100000); /* wait a little for server setup */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3198 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3199 ioloop = io_loop_create(); |
21051
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
3200 if (client_test(client_set)) |
dfbc24ac8700
lib-http: Added blocking client support to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21050
diff
changeset
|
3201 io_loop_run(ioloop); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3202 test_client_deinit(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3203 io_loop_destroy(&ioloop); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3204 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3205 test_servers_kill_all(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3206 i_free(server_pids); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3207 i_free(bind_ports); |
21049
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3208 |
dbbf345febf2
lib-http: Added DNS-related tests to test-http-client-errors.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21026
diff
changeset
|
3209 i_unlink_if_exists("./dns-test"); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3210 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3211 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3212 /* |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3213 * Main |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3214 */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3215 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3216 volatile sig_atomic_t terminating = 0; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3217 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3218 static void |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3219 test_signal_handler(int signo) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3220 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3221 if (terminating) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3222 raise(signo); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3223 terminating = 1; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3224 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3225 /* make sure we don't leave any pesky children alive */ |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3226 test_servers_kill_all(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3227 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3228 (void)signal(signo, SIG_DFL); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3229 raise(signo); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3230 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3231 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3232 static void test_atexit(void) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3233 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3234 test_servers_kill_all(); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3235 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3236 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3237 int main(int argc, char *argv[]) |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3238 { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3239 int c; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3240 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3241 atexit(test_atexit); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3242 (void)signal(SIGCHLD, SIG_IGN); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3243 (void)signal(SIGTERM, test_signal_handler); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3244 (void)signal(SIGQUIT, test_signal_handler); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3245 (void)signal(SIGINT, test_signal_handler); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3246 (void)signal(SIGSEGV, test_signal_handler); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3247 (void)signal(SIGABRT, test_signal_handler); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3248 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3249 while ((c = getopt(argc, argv, "D")) > 0) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3250 switch (c) { |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3251 case 'D': |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3252 debug = TRUE; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3253 break; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3254 default: |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3255 i_fatal("Usage: %s [-D]", argv[0]); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3256 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3257 } |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3258 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3259 /* listen on localhost */ |
21389
59437f8764c6
global: Replaced all instances of memset(p, 0, sizeof(*p)) with the new i_zero() macro.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents:
21336
diff
changeset
|
3260 i_zero(&bind_ip); |
20360
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3261 bind_ip.family = AF_INET; |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3262 bind_ip.u.ip4.s_addr = htonl(INADDR_LOOPBACK); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3263 |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3264 test_run(test_functions); |
2ce144c4dbd7
lib-http: client: Created test program that triggers most possible error conditions.
Stephan Bosch <stephan@dovecot.fi>
parents:
diff
changeset
|
3265 } |