diff --git a/src/lib-http/http-client-connection.c b/src/lib-http/http-client-connection.c index ada387c2d6..d2000453b9 100644 --- a/src/lib-http/http-client-connection.c +++ b/src/lib-http/http-client-connection.c @@ -1184,6 +1184,7 @@ http_client_connection_connected(struct connection *_conn, bool success) { struct http_client_connection *conn = (struct http_client_connection *)_conn; + const struct http_client_settings *set = &conn->client->set; const char *error; if (!success) { @@ -1192,6 +1193,18 @@ http_client_connection_connected(struct connection *_conn, bool success) } else { conn->connected_timestamp = ioloop_timeval; http_client_connection_debug(conn, "Connected"); + + if (set->socket_send_buffer_size > 0) { + if (net_set_send_buffer_size(_conn->fd_out, + set->socket_send_buffer_size) < 0) + i_error("net_set_send_buffer_size() failed: %m"); + } + if (set->socket_recv_buffer_size > 0) { + if (net_set_recv_buffer_size(_conn->fd_in, + set->socket_recv_buffer_size) < 0) + i_error("net_set_recv_buffer_size() failed: %m"); + } + if (http_client_peer_addr_is_https(&conn->peer->addr)) { if (http_client_connection_ssl_init(conn, &error) < 0) { http_client_peer_connection_failure(conn->peer, error); diff --git a/src/lib-http/http-client.c b/src/lib-http/http-client.c index a97aea4886..ec1cba878e 100644 --- a/src/lib-http/http-client.c +++ b/src/lib-http/http-client.c @@ -145,6 +145,8 @@ struct http_client *http_client_init(const struct http_client_settings *set) client->set.connect_timeout_msecs = set->connect_timeout_msecs; client->set.soft_connect_timeout_msecs = set->soft_connect_timeout_msecs; client->set.max_auto_retry_delay = set->max_auto_retry_delay; + client->set.socket_send_buffer_size = set->socket_send_buffer_size; + client->set.socket_recv_buffer_size = set->socket_recv_buffer_size; client->set.debug = set->debug; i_array_init(&client->delayed_failing_requests, 1); diff --git a/src/lib-http/http-client.h b/src/lib-http/http-client.h index 4a58d83816..51a7097191 100644 --- a/src/lib-http/http-client.h +++ b/src/lib-http/http-client.h @@ -109,6 +109,12 @@ struct http_client_settings { is not automatically retried and the response is returned */ unsigned int max_auto_retry_delay; + /* the kernel send/receive buffer sizes used for the connection sockets. + Configuring this is mainly useful for the test suite. The kernel + defaults are used when these settings are 0. */ + size_t socket_send_buffer_size; + size_t socket_recv_buffer_size; + /* enable logging debug messages */ bool debug; };