diff options
author | Ladar Levison <ladar@lavabit.com> | 2017-04-04 00:51:36 +0300 |
---|---|---|
committer | Ladar Levison <ladar@lavabit.com> | 2017-04-04 00:51:36 +0300 |
commit | f1bb314aba2d5c0f51e6c299c370d8e8b434181f (patch) | |
tree | c2ac36c322b322392aae5325f59349d14a9c23a5 /check/magma/servers/http/http_check_network.c | |
parent | e74acf1a534f9fc865b365d357f0734b8b2f1f05 (diff) |
Network check code review and cleanup. Better regex error logging.feature/tls-error-investigation
Diffstat (limited to 'check/magma/servers/http/http_check_network.c')
-rw-r--r-- | check/magma/servers/http/http_check_network.c | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/check/magma/servers/http/http_check_network.c b/check/magma/servers/http/http_check_network.c index b4928eb0..5675d664 100644 --- a/check/magma/servers/http/http_check_network.c +++ b/check/magma/servers/http/http_check_network.c @@ -111,31 +111,26 @@ bool_t check_http_network_basic_sthread(stringer_t *errmsg, uint32_t port, bool_ client_t *client = NULL; // Test the connection. - if (!(client = client_connect("localhost", port)) || (secure && (client_secure(client) == -1)) || - client_status(client) != 1) { - + if (!(client = client_connect("localhost", port)) || (secure && (client_secure(client) == -1)) || client_status(client) != 1) { st_sprint(errmsg, "Failed to connect with the HTTP server."); client_close(client); return false; } // Test submitting a GET request. - else if (client_write(client, PLACER("GET / HTTP/1.1\r\nHost: localhost\r\n\r\n", 35)) != 35 || client_status(client) != 1 || - !(content_length = check_http_content_length_get(client, errmsg))) { - + else if (client_write(client, PLACER("GET / HTTP/1.1\r\nHost: localhost\r\n\r\n", 35)) != 35 || + client_status(client) != 1 || !(content_length = check_http_content_length_get(client, errmsg))) { if (st_empty(errmsg)) st_sprint(errmsg, "Failed to return a valid GET response."); client_close(client); return false; } // Test the response. else if (check_http_content_length_test(client, content_length, errmsg)) { - if (st_empty(errmsg)) st_sprint(errmsg, "The content length and actual body length of the GET response did not match."); client_close(client); return false; } client_close(client); - return true; } @@ -153,17 +148,14 @@ bool_t check_http_network_options_sthread(stringer_t *errmsg, uint32_t port, boo }; // Test the connection. - if (!(client = client_connect("localhost", port)) || (secure && (client_secure(client) == -1)) || - client_status(client) != 1) { - + if (!(client = client_connect("localhost", port)) || (secure && (client_secure(client) == -1)) || client_status(client) != 1) { st_sprint(errmsg, "Failed to connect with the HTTP server."); client_close(client); return false; } - // Test OPTIONS - else if (client_write(client, PLACER("OPTIONS /portal/camel HTTP/1.1\r\n\r\n", 34)) != 34 || client_status(client) != 1 || - !check_http_options(client, options, errmsg)) { - + // Test OPTIONS. + else if (client_write(client, PLACER("OPTIONS /portal/camel HTTP/1.1\r\n\r\n", 34)) != 34 || + client_status(client) != 1 || !check_http_options(client, options, errmsg)) { client_close(client); return false; } |