rspamd_http_connection_reset (c->http_conn);
rspamd_http_connection_read_message (c->http_conn,
c->req,
- c->fd,
- &c->timeout,
- c->ev_base);
+ &c->timeout);
return 0;
}
else {
conn->fd = fd;
conn->req_sent = FALSE;
conn->http_conn = rspamd_http_connection_new (http_ctx,
+ fd,
rspamd_client_body_handler,
rspamd_client_error_handler,
rspamd_client_finish_handler,
if (compressed) {
rspamd_http_connection_write_message (conn->http_conn, req->msg, NULL,
- "application/x-compressed", req, conn->fd,
- &conn->timeout, conn->ev_base);
+ "application/x-compressed", req,
+ &conn->timeout);
}
else {
rspamd_http_connection_write_message (conn->http_conn, req->msg, NULL,
- "text/plain", req, conn->fd, &conn->timeout, conn->ev_base);
+ "text/plain", req, &conn->timeout);
}
return TRUE;
rspamd_http_connection_reset (conn_ent->conn);
rspamd_http_router_insert_headers (conn_ent->rt, reply);
rspamd_http_connection_write_message (conn_ent->conn, reply, NULL,
- "text/plain", conn_ent, conn_ent->conn->fd,
- conn_ent->rt->ptv, conn_ent->rt->ev_base);
+ "text/plain", conn_ent,
+ conn_ent->rt->ptv);
conn_ent->is_reply = TRUE;
return 0;
rspamd_http_connection_reset (conn_ent->conn);
rspamd_http_router_insert_headers (conn_ent->rt, msg);
rspamd_http_connection_write_message (conn_ent->conn, msg, NULL,
- "application/json", conn_ent, conn_ent->conn->fd, conn_ent->rt->ptv,
- conn_ent->rt->ev_base);
+ "application/json", conn_ent, conn_ent->rt->ptv);
conn_ent->is_reply = TRUE;
}
NULL,
"text/plain",
conn_ent,
- conn_ent->conn->fd,
- conn_ent->rt->ptv,
- conn_ent->rt->ev_base);
+ conn_ent->rt->ptv);
conn_ent->is_reply = TRUE;
return 0;
NULL,
"text/plain",
conn_ent,
- conn_ent->conn->fd,
- conn_ent->rt->ptv,
- conn_ent->rt->ev_base);
+ conn_ent->rt->ptv);
conn_ent->is_reply = TRUE;
}
else {
NULL,
"text/plain",
conn_ent,
- conn_ent->conn->fd,
- conn_ent->rt->ptv,
- conn_ent->rt->ev_base);
+ conn_ent->rt->ptv);
conn_ent->is_reply = TRUE;
}
double_to_tv (ctx->sync_timeout, &tv);
rspamd_http_connection_write_message (conn->http_conn,
msg, NULL, NULL, conn,
- conn->sock,
- &tv, ctx->ev_base);
+ &tv);
msg_info ("send update request to %s", m->name);
g_array_free (cbdata->updates_pending, TRUE);
conn->http_conn = rspamd_http_connection_new (
ctx->http_ctx,
+ conn->sock,
NULL,
fuzzy_mirror_error_handler,
fuzzy_mirror_finish_handler,
rspamd_http_connection_reset (session->conn);
rspamd_http_connection_write_message (session->conn, msg, NULL, "text/plain",
- session, session->sock, &session->ctx->master_io_tv,
- session->ctx->ev_base);
+ session, &session->ctx->master_io_tv);
}
static void
NULL,
"text/plain",
entry,
- entry->conn->fd,
- entry->rt->ptv,
- entry->rt->ev_base);
+ entry->rt->ptv);
entry->is_reply = TRUE;
}
NULL,
"application/octet-stream",
entry,
- entry->conn->fd,
- entry->rt->ptv,
- entry->rt->ev_base);
+ entry->rt->ptv);
entry->is_reply = TRUE;
}
session->uid[sizeof (session->uid) - 1] = '\0';
http_conn = rspamd_http_connection_new (
ctx->http_ctx,
+ nfd,
NULL,
rspamd_fuzzy_mirror_error_handler,
rspamd_fuzzy_mirror_finish_handler,
rspamd_http_connection_read_message (http_conn,
session,
- nfd,
- &ctx->master_io_tv,
- ctx->ev_base);
+ &ctx->master_io_tv);
}
/*
rspamd_http_connection_reset (task->http_conn);
rspamd_http_connection_write_message (task->http_conn, msg, NULL,
- ctype, task, task->sock, &task->tv, task->ev_base);
+ ctype, task, &task->tv);
task->processed_stages |= RSPAMD_TASK_STAGE_REPLIED;
}
NULL,
"application/json",
session,
- session->fd,
- &io_timeout,
- session->rspamd_main->ev_base);
+ &io_timeout);
}
static void
NULL,
"application/json",
session,
- session->fd,
- &io_timeout,
- session->rspamd_main->ev_base);
+ &io_timeout);
}
static void
session->fd = fd;
session->conn = rspamd_http_connection_new (rspamd_main->http_ctx,
+ fd,
NULL,
rspamd_control_error_handler,
rspamd_control_finish_handler,
0,
RSPAMD_HTTP_SERVER);
session->rspamd_main = rspamd_main;
- rspamd_http_connection_read_message (session->conn, session, session->fd,
- &io_timeout, rspamd_main->ev_base);
+ rspamd_http_connection_read_message (session->conn, session,
+ &io_timeout);
}
struct rspamd_worker_control_data {
NULL,
"application/json",
entry,
- entry->conn->fd,
- entry->rt->ptv,
- entry->rt->ev_base);
+ entry->rt->ptv);
entry->is_reply = TRUE;
}
NULL,
"application/json",
entry,
- entry->conn->fd,
- entry->rt->ptv,
- entry->rt->ev_base);
+ entry->rt->ptv);
entry->is_reply = TRUE;
}
NULL,
"application/json",
entry,
- entry->conn->fd,
- entry->rt->ptv,
- entry->rt->ev_base);
+ entry->rt->ptv);
entry->is_reply = TRUE;
}
static void
rspamd_http_simple_client_helper (struct rspamd_http_connection *conn)
{
- struct event_base *base;
struct rspamd_http_connection_private *priv;
gpointer ssl;
gint request_method;
priv = conn->priv;
- base = conn->priv->ev.ev_base;
ssl = priv->ssl;
priv->ssl = NULL;
request_method = priv->msg->method;
/* Plan read message */
if (conn->opts & RSPAMD_HTTP_CLIENT_SHARED) {
- rspamd_http_connection_read_message_shared (conn, conn->ud, conn->fd,
- conn->priv->ptv, base);
+ rspamd_http_connection_read_message_shared (conn, conn->ud,
+ conn->priv->ptv);
}
else {
- rspamd_http_connection_read_message (conn, conn->ud, conn->fd,
- conn->priv->ptv, base);
+ rspamd_http_connection_read_message (conn, conn->ud,
+ conn->priv->ptv);
}
priv->msg->method = request_method;
struct rspamd_http_connection *
rspamd_http_connection_new (
struct rspamd_http_context *ctx,
+ gint fd,
rspamd_http_body_handler_t body_handler,
rspamd_http_error_handler_t error_handler,
rspamd_http_finish_handler_t finish_handler,
conn->body_handler = body_handler;
conn->error_handler = error_handler;
conn->finish_handler = finish_handler;
- conn->fd = -1;
+ conn->fd = fd;
conn->ref = 1;
conn->finished = FALSE;
static void
rspamd_http_connection_read_message_common (struct rspamd_http_connection *conn,
- gpointer ud, gint fd, struct timeval *timeout, struct event_base *base,
+ gpointer ud, struct timeval *timeout,
gint flags)
{
struct rspamd_http_connection_private *priv = conn->priv;
struct rspamd_http_message *req;
- conn->fd = fd;
conn->ud = ud;
req = rspamd_http_new_message (
conn->type == RSPAMD_HTTP_SERVER ? HTTP_REQUEST : HTTP_RESPONSE);
priv->flags |= RSPAMD_HTTP_CONN_FLAG_NEW_HEADER;
event_set (&priv->ev,
- fd,
+ conn->fd,
EV_READ | EV_PERSIST,
rspamd_http_event_handler,
conn);
- if (base != NULL) {
- event_base_set (base, &priv->ev);
- }
+
+ event_base_set (priv->ctx->ev_base, &priv->ev);
priv->flags &= ~RSPAMD_HTTP_CONN_FLAG_RESETED;
event_add (&priv->ev, priv->ptv);
void
rspamd_http_connection_read_message (struct rspamd_http_connection *conn,
- gpointer ud, gint fd, struct timeval *timeout, struct event_base *base)
+ gpointer ud, struct timeval *timeout)
{
- rspamd_http_connection_read_message_common (conn, ud, fd, timeout, base, 0);
+ rspamd_http_connection_read_message_common (conn, ud, timeout, 0);
}
void
rspamd_http_connection_read_message_shared (struct rspamd_http_connection *conn,
- gpointer ud, gint fd, struct timeval *timeout, struct event_base *base)
+ gpointer ud, struct timeval *timeout)
{
- rspamd_http_connection_read_message_common (conn, ud, fd, timeout, base,
+ rspamd_http_connection_read_message_common (conn, ud, timeout,
RSPAMD_HTTP_FLAG_SHMEM);
}
static void
rspamd_http_connection_write_message_common (struct rspamd_http_connection *conn,
- struct rspamd_http_message *msg, const gchar *host, const gchar *mime_type,
- gpointer ud, gint fd, struct timeval *timeout, struct event_base *base,
- gboolean allow_shared)
+ struct rspamd_http_message *msg,
+ const gchar *host,
+ const gchar *mime_type,
+ gpointer ud,
+ struct timeval *timeout,
+ gboolean allow_shared)
{
struct rspamd_http_connection_private *priv = conn->priv;
struct rspamd_http_header *hdr, *htmp, *hcur;
enum rspamd_cryptobox_mode mode;
GError *err;
- conn->fd = fd;
conn->ud = ud;
priv->msg = msg;
gpointer ssl_ctx = (msg->flags & RSPAMD_HTTP_FLAG_SSL_NOVERIFY) ?
priv->ctx->ssl_ctx_noverify : priv->ctx->ssl_ctx;
- if (base != NULL) {
- event_base_set (base, &priv->ev);
- }
+ event_base_set (priv->ctx->ev_base, &priv->ev);
if (!ssl_ctx) {
err = g_error_new (HTTP_ERROR, errno, "ssl message requested "
rspamd_ssl_connection_free (priv->ssl);
}
- priv->ssl = rspamd_ssl_connection_new (ssl_ctx, base,
+ priv->ssl = rspamd_ssl_connection_new (ssl_ctx, priv->ctx->ev_base,
!(msg->flags & RSPAMD_HTTP_FLAG_SSL_NOVERIFY));
g_assert (priv->ssl != NULL);
- if (!rspamd_ssl_connect_fd (priv->ssl, fd, host, &priv->ev,
+ if (!rspamd_ssl_connect_fd (priv->ssl, conn->fd, host, &priv->ev,
priv->ptv, rspamd_http_event_handler,
rspamd_http_ssl_err_handler, conn)) {
}
}
else {
- event_set (&priv->ev, fd, EV_WRITE, rspamd_http_event_handler, conn);
-
- if (base != NULL) {
- event_base_set (base, &priv->ev);
- }
+ event_set (&priv->ev, conn->fd, EV_WRITE, rspamd_http_event_handler, conn);
+ event_base_set (priv->ctx->ev_base, &priv->ev);
event_add (&priv->ev, priv->ptv);
}
void
rspamd_http_connection_write_message (struct rspamd_http_connection *conn,
- struct rspamd_http_message *msg, const gchar *host, const gchar *mime_type,
- gpointer ud, gint fd, struct timeval *timeout, struct event_base *base)
+ struct rspamd_http_message *msg,
+ const gchar *host,
+ const gchar *mime_type,
+ gpointer ud,
+ struct timeval *timeout)
{
rspamd_http_connection_write_message_common (conn, msg, host, mime_type,
- ud, fd, timeout, base, FALSE);
+ ud, timeout, FALSE);
}
void
rspamd_http_connection_write_message_shared (struct rspamd_http_connection *conn,
- struct rspamd_http_message *msg, const gchar *host, const gchar *mime_type,
- gpointer ud, gint fd, struct timeval *timeout, struct event_base *base)
+ struct rspamd_http_message *msg,
+ const gchar *host,
+ const gchar *mime_type,
+ gpointer ud,
+ struct timeval *timeout)
{
rspamd_http_connection_write_message_common (conn, msg, host, mime_type,
- ud, fd, timeout, base, TRUE);
+ ud, timeout, TRUE);
}
}
}
-
rspamd_http_message_storage_cleanup (msg);
if (msg->url != NULL) {
* Do not verify server's certificate
*/
#define RSPAMD_HTTP_FLAG_SSL_NOVERIFY (1 << 6)
+/**
+ * Do not verify server's certificate
+ */
+#define RSPAMD_HTTP_FLAG_KEEPALIVE (1 << 7)
/**
* Options for HTTP connection
*/
enum rspamd_http_options {
- RSPAMD_HTTP_BODY_PARTIAL = 0x1, /**< Call body handler on all body data portions *///!< RSPAMD_HTTP_BODY_PARTIAL
- RSPAMD_HTTP_CLIENT_SIMPLE = 0x1u << 1, /**< Read HTTP client reply automatically */ //!< RSPAMD_HTTP_CLIENT_SIMPLE
- RSPAMD_HTTP_CLIENT_ENCRYPTED = 0x1u << 2, /**< Encrypt data for client */ //!< RSPAMD_HTTP_CLIENT_ENCRYPTED
- RSPAMD_HTTP_CLIENT_SHARED = 0x1u << 3, /**< Store reply in shared memory */ //!< RSPAMD_HTTP_CLIENT_SHARED
- RSPAMD_HTTP_REQUIRE_ENCRYPTION = 0x1u << 4
+ RSPAMD_HTTP_BODY_PARTIAL = 1, /**< Call body handler on all body data portions */
+ RSPAMD_HTTP_CLIENT_SIMPLE = 1u << 1, /**< Read HTTP client reply automatically */
+ RSPAMD_HTTP_CLIENT_ENCRYPTED = 1u << 2, /**< Encrypt data for client */
+ RSPAMD_HTTP_CLIENT_SHARED = 1u << 3, /**< Store reply in shared memory */
+ RSPAMD_HTTP_REQUIRE_ENCRYPTION = 1u << 4,
+ RSPAMD_HTTP_CLIENT_KEEP_ALIVE = 1u << 5,
};
typedef int (*rspamd_http_body_handler_t) (struct rspamd_http_connection *conn,
*/
struct rspamd_http_connection *rspamd_http_connection_new (
struct rspamd_http_context *ctx,
+ gint fd,
rspamd_http_body_handler_t body_handler,
rspamd_http_error_handler_t error_handler,
rspamd_http_finish_handler_t finish_handler,
void rspamd_http_connection_read_message (
struct rspamd_http_connection *conn,
gpointer ud,
- gint fd,
- struct timeval *timeout,
- struct event_base *base);
+ struct timeval *timeout);
void rspamd_http_connection_read_message_shared (
struct rspamd_http_connection *conn,
gpointer ud,
- gint fd,
- struct timeval *timeout,
- struct event_base *base);
+ struct timeval *timeout);
/**
* Send reply using initialised connection
const gchar *host,
const gchar *mime_type,
gpointer ud,
- gint fd,
- struct timeval *timeout,
- struct event_base *base);
+ struct timeval *timeout);
void rspamd_http_connection_write_message_shared (
struct rspamd_http_connection *conn,
const gchar *host,
const gchar *mime_type,
gpointer ud,
- gint fd,
- struct timeval *timeout,
- struct event_base *base);
+ struct timeval *timeout);
/**
* Free connection structure
NULL,
"text/plain",
entry,
- entry->conn->fd,
- entry->rt->ptv,
- entry->rt->ev_base);
+ entry->rt->ptv);
entry->is_reply = TRUE;
}
}
msg_debug ("requested file %s", realbuf);
rspamd_http_connection_write_message (entry->conn, reply_msg, NULL,
- rspamd_http_router_detect_ct (realbuf), entry, entry->conn->fd,
- entry->rt->ptv, entry->rt->ev_base);
+ rspamd_http_router_detect_ct (realbuf), entry,
+ entry->rt->ptv);
return TRUE;
}
NULL,
"text/plain",
entry,
- entry->conn->fd,
- entry->rt->ptv,
- entry->rt->ev_base);
+ entry->rt->ptv);
}
conn->is_reply = FALSE;
conn->conn = rspamd_http_connection_new (router->ctx,
+ fd,
NULL,
rspamd_http_router_error_handler,
rspamd_http_router_finish_handler,
rspamd_http_connection_set_key (conn->conn, router->key);
}
- rspamd_http_connection_read_message (conn->conn, conn, fd, router->ptv,
- router->ev_base);
+ rspamd_http_connection_read_message (conn->conn, conn, router->ptv);
DL_PREPEND (router->conns, conn);
}
cbd->data->host,
NULL,
cbd,
- cbd->fd,
- &cbd->tv,
- cbd->ev_base);
+ &cbd->tv);
}
else {
msg_err_map ("cannot connect to %s: %s", cbd->data->host,
if (cbd->fd != -1) {
cbd->stage = map_load_file;
cbd->conn = rspamd_http_connection_new (NULL,
+ cbd->fd,
NULL,
http_map_error,
http_map_finish,
cbd->conn = rspamd_http_connection_new (
NULL,
NULL,
+ cbd->fd,
http_map_error,
http_map_finish,
flags,
if (cbd->cfg) {
cbd->conn = rspamd_http_connection_new (
NULL,
+ fd,
NULL,
lua_http_error_handler,
lua_http_finish_handler,
else {
cbd->conn = rspamd_http_connection_new (
NULL,
+ fd,
NULL,
lua_http_error_handler,
lua_http_finish_handler,
cbd->msg = NULL;
rspamd_http_connection_write_message (cbd->conn, msg,
- cbd->host, cbd->mime_type, cbd, fd,
- &cbd->tv, cbd->ev_base);
+ cbd->host, cbd->mime_type, cbd,
+ &cbd->tv);
return TRUE;
}
param->url = url;
param->task = task;
param->conn = rspamd_http_connection_new (NULL,
+ s,
NULL,
surbl_redirector_error,
surbl_redirector_finish,
}
rspamd_http_connection_write_message (param->conn, msg, NULL,
- NULL, param, s, timeout, task->ev_base);
+ NULL, param, timeout);
msg_info_surbl (
"<%s> registered redirector call for %*s to %s, according to rule: %s",
conn = rspamd_http_connection_new (
NULL, /* Default context */
+ sock,
NULL,
rspamd_control_error_handler,
rspamd_control_finish_handler,
cbdata.argv = argv;
cbdata.path = path;
- rspamd_http_connection_write_message (conn, msg, NULL, NULL, &cbdata, sock,
- &tv, ev_base);
+ rspamd_http_connection_write_message (conn, msg, NULL, NULL, &cbdata,
+ &tv);
event_base_loop (ev_base, 0);
bk_conn->backend_conn = rspamd_http_connection_new (
session->ctx->http_ctx,
+ bk_conn->backend_sock,
NULL,
proxy_backend_mirror_error_handler,
proxy_backend_mirror_finish_handler,
msg->method = HTTP_GET;
rspamd_http_connection_write_message_shared (bk_conn->backend_conn,
msg, NULL, NULL, bk_conn,
- bk_conn->backend_sock,
- bk_conn->io_tv, session->ctx->ev_base);
+ bk_conn->io_tv);
}
else {
if (session->fname) {
rspamd_http_connection_write_message (bk_conn->backend_conn,
msg, NULL, NULL, bk_conn,
- bk_conn->backend_sock,
- bk_conn->io_tv, session->ctx->ev_base);
+ bk_conn->io_tv);
}
g_ptr_array_add (session->mirror_conns, bk_conn);
reply->code = code;
reply->status = rspamd_fstring_new_init (status, strlen (status));
rspamd_http_connection_write_message (session->client_conn,
- reply, NULL, NULL, session, session->client_sock,
- &session->ctx->io_tv, session->ctx->ev_base);
+ reply, NULL, NULL, session,
+ &session->ctx->io_tv);
}
}
}
else {
rspamd_http_connection_write_message (session->client_conn,
- msg, NULL, NULL, session, session->client_sock,
- bk_conn->io_tv, session->ctx->ev_base);
+ msg, NULL, NULL, session,
+ bk_conn->io_tv);
}
return 0;
NULL,
ctype,
session,
- session->client_sock,
- NULL,
- session->ctx->ev_base);
+ NULL);
}
}
session->master_conn->backend_conn = rspamd_http_connection_new (
session->ctx->http_ctx,
+ session->master_conn->backend_sock,
NULL,
proxy_backend_master_error_handler,
proxy_backend_master_finish_handler,
rspamd_http_connection_write_message_shared (
session->master_conn->backend_conn,
msg, NULL, NULL, session->master_conn,
- session->master_conn->backend_sock,
- session->master_conn->io_tv, session->ctx->ev_base);
+ session->master_conn->io_tv);
}
else {
if (session->fname) {
rspamd_http_connection_write_message (
session->master_conn->backend_conn,
msg, NULL, NULL, session->master_conn,
- session->master_conn->backend_sock,
- session->master_conn->io_tv, session->ctx->ev_base);
+ session->master_conn->io_tv);
}
}
if (!ctx->milter) {
session->client_conn = rspamd_http_connection_new (
ctx->http_ctx,
+ nfd,
NULL,
proxy_client_error_handler,
proxy_client_finish_handler,
rspamd_http_connection_read_message_shared (session->client_conn,
session,
- nfd,
- &ctx->io_tv,
- ctx->ev_base);
+ &ctx->io_tv);
}
else {
msg_info_session ("accepted milter connection from %s port %d",
NULL,
"application/json",
task,
- task->http_conn->fd,
- &task->tv,
- task->ev_base);
+ &task->tv);
}
}
task->http_conn = rspamd_http_connection_new (
ctx->http_ctx,
+ nfd,
rspamd_worker_body_handler,
rspamd_worker_error_handler,
rspamd_worker_finish_handler,
rspamd_http_connection_read_message (task->http_conn,
task,
- nfd,
- &ctx->io_tv,
- ctx->ev_base);
+ &ctx->io_tv);
}
#ifdef WITH_HYPERSCAN