(struct rspamd_http_connection *)parser->data;
struct rspamd_http_connection_private *priv;
struct rspamd_http_message *msg;
+ int ret;
priv = conn->priv;
msg = priv->msg;
priv->flags &= ~RSPAMD_HTTP_CONN_FLAG_NEW_HEADER;
}
+ if (msg->method == HTTP_HEAD) {
+ /* We don't care about the rest */
+ if (event_pending (&priv->ev, EV_READ, NULL)) {
+ event_del (&priv->ev);
+ }
+
+ msg->code = parser->status_code;
+ rspamd_http_connection_ref (conn);
+ ret = conn->finish_handler (conn, msg);
+ conn->finished = TRUE;
+ rspamd_http_connection_unref (conn);
+
+ return ret;
+ }
+
/*
* HTTP parser sets content length to (-1) when it doesn't know the real
* length, for example, in case of chunked encoding.
struct rspamd_http_connection *conn =
(struct rspamd_http_connection *) parser->data;
struct rspamd_http_connection_private *priv;
+ struct rspamd_http_message *msg;
+ int ret;
priv = conn->priv;
+ msg = priv->msg;
if (priv->header != NULL) {
rspamd_http_finish_header (conn, priv);
priv->msg->flags |= RSPAMD_HTTP_FLAG_SPAMC;
}
+ if (msg->method == HTTP_HEAD) {
+ /* We don't care about the rest */
+ if (event_pending (&priv->ev, EV_READ, NULL)) {
+ event_del (&priv->ev);
+ }
+
+ msg->code = parser->status_code;
+ rspamd_http_connection_ref (conn);
+ ret = conn->finish_handler (conn, msg);
+ conn->finished = TRUE;
+ rspamd_http_connection_unref (conn);
+
+ return ret;
+ }
+
priv->msg->method = parser->method;
priv->msg->code = parser->status_code;
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;
rspamd_http_connection_reset (conn);
priv->ssl = ssl;
/* Plan read message */
rspamd_http_connection_read_message (conn, conn->ud, conn->fd,
conn->priv->ptv, base);
}
+
+ priv->msg->method = request_method;
}
static void
"IO read error: unexpected EOF");
conn->error_handler (conn, err);
g_error_free (err);
-
-
}
REF_RELEASE (pbuf);
rspamd_http_connection_unref (conn);
if (conn->state != ssl_conn_connected && conn->state != ssl_next_read) {
errno = EINVAL;
+ g_set_error (&err, rspamd_ssl_quark (), ECONNRESET,
+ "ssl state error: cannot read data");
+ conn->err_handler (conn->handler_data, err);
+ g_error_free (err);
+
return -1;
}
else {
ret = SSL_get_error (conn->ssl, ret);
conn->state = ssl_next_read;
+ what = 0;
if (ret == SSL_ERROR_WANT_READ) {
- what = EV_READ;
+ what |= EV_READ;
}
else if (ret == SSL_ERROR_WANT_WRITE) {
- what = EV_WRITE;
+ what |= EV_WRITE;
}
else {
g_set_error (&err, rspamd_ssl_quark (), ret,
ret = SSL_get_error (conn->ssl, ret);
if (ret == SSL_ERROR_ZERO_RETURN) {
+ g_set_error (&err, rspamd_ssl_quark (), ret,
+ "ssl write error: %s", ERR_error_string (ret, NULL));
+ conn->err_handler (conn->handler_data, err);
+ g_error_free (err);
+ errno = ECONNRESET;
conn->state = ssl_conn_reset;
- return 0;
+
+ return -1;
}
else {
g_set_error (&err, rspamd_ssl_quark (), ret,