return &http_err_chunks[msgnum];
}
+void
+http_reply_and_close(struct stream *s, short status, struct chunk *msg)
+{
+ stream_int_retnclose(&s->si[0], msg);
+}
+
/*
* returns a known method among HTTP_METH_* or HTTP_METH_OTHER for all unknown
* ones.
}
txn->status = 400;
- stream_int_retnclose(&s->si[0], NULL);
msg->msg_state = HTTP_MSG_ERROR;
+ http_reply_and_close(s, txn->status, NULL);
req->analysers = 0;
stream_inc_http_req_ctr(s);
stream_inc_http_err_ctr(s);
}
txn->status = 408;
- stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_408));
msg->msg_state = HTTP_MSG_ERROR;
+ http_reply_and_close(s, txn->status, http_error_message(s, HTTP_ERR_408));
req->analysers = 0;
stream_inc_http_req_ctr(s);
if (msg->err_pos >= 0)
http_capture_bad_message(&sess->fe->invalid_req, s, msg, msg->msg_state, sess->fe);
txn->status = 400;
- stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_400));
msg->msg_state = HTTP_MSG_ERROR;
+ http_reply_and_close(s, txn->status, http_error_message(s, HTTP_ERR_400));
req->analysers = 0;
stream_inc_http_err_ctr(s);
s->logs.logwait = 0;
s->logs.level = 0;
s->res.flags &= ~CF_EXPECT_MORE; /* speed up sending a previous response */
- stream_int_retnclose(&s->si[0], NULL);
+ http_reply_and_close(s, txn->status, NULL);
return 0;
}
if (ret) {
/* we fail this request, let's return 503 service unavail */
txn->status = 503;
- stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_503));
+ http_reply_and_close(s, txn->status, http_error_message(s, HTTP_ERR_503));
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_LOCAL; /* we don't want a real error here */
goto return_prx_cond;
/* nothing to fail, let's reply normaly */
txn->status = 200;
- stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_200));
+ http_reply_and_close(s, txn->status, http_error_message(s, HTTP_ERR_200));
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_LOCAL; /* we don't want a real error here */
goto return_prx_cond;
txn->req.msg_state = HTTP_MSG_ERROR;
txn->status = 400;
- stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_400));
+ http_reply_and_close(s, txn->status, http_error_message(s, HTTP_ERR_400));
sess->fe->fe_counters.failed_req++;
if (sess->listener->counters)
*/
chunk_printf(&trash, (txn->flags & TX_USE_PX_CONN) ? HTTP_407_fmt : HTTP_401_fmt, auth_realm);
txn->status = (txn->flags & TX_USE_PX_CONN) ? 407 : 401;
- stream_int_retnclose(&s->si[0], &trash);
+ http_reply_and_close(s, txn->status, &trash);
stream_inc_http_err_ctr(s);
return HTTP_RULE_RES_ABRT;
memcpy(trash.str + trash.len, "\r\nConnection: close\r\n\r\n", 23);
trash.len += 23;
}
- stream_int_retnclose(&s->si[0], &trash);
+ http_reply_and_close(s, txn->status, &trash);
req->chn->analysers = 0;
}
if (unlikely(!stream_int_register_handler(&s->si[1], objt_applet(s->target)))) {
txn->status = 500;
s->logs.tv_request = now;
- stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_500));
+ http_reply_and_close(s, txn->status, http_error_message(s, HTTP_ERR_500));
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_RESOURCE;
txn->flags |= TX_CLDENY;
txn->status = http_err_codes[txn->rule_deny_status];
s->logs.tv_request = now;
- stream_int_retnclose(&s->si[0], http_error_message(s, txn->rule_deny_status));
+ http_reply_and_close(s, txn->status, http_error_message(s, txn->rule_deny_status));
stream_inc_http_err_ctr(s);
sess->fe->fe_counters.denied_req++;
if (sess->fe != s->be)
txn->req.msg_state = HTTP_MSG_ERROR;
txn->status = 400;
- stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_400));
+ http_reply_and_close(s, txn->status, http_error_message(s, HTTP_ERR_400));
sess->fe->fe_counters.failed_req++;
if (sess->listener->counters)
txn->req.msg_state = HTTP_MSG_ERROR;
txn->status = 500;
req->analysers = 0;
- stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_500));
+ http_reply_and_close(s, txn->status, http_error_message(s, HTTP_ERR_500));
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_RESOURCE;
txn->req.msg_state = HTTP_MSG_ERROR;
txn->status = 400;
req->analysers = 0;
- stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_400));
+ http_reply_and_close(s, txn->status, http_error_message(s, HTTP_ERR_400));
sess->fe->fe_counters.failed_req++;
if (sess->listener->counters)
txn->status = 500;
if (!(req->flags & CF_READ_ERROR))
- stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_500));
+ http_reply_and_close(s, txn->status, http_error_message(s, HTTP_ERR_500));
req->analysers = 0;
req->analyse_exp = TICK_ETERNITY;
if ((req->flags & CF_READ_TIMEOUT) || tick_is_expired(req->analyse_exp, now_ms)) {
txn->status = 408;
- stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_408));
+ http_reply_and_close(s, txn->status, http_error_message(s, HTTP_ERR_408));
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_CLITO;
return_bad_req: /* let's centralize all bad requests */
txn->req.msg_state = HTTP_MSG_ERROR;
txn->status = 400;
- stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_400));
+ http_reply_and_close(s, txn->status, http_error_message(s, HTTP_ERR_400));
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_PRXCOND;
txn->req.msg_state = HTTP_MSG_ERROR;
if (txn->status) {
/* Note: we don't send any error if some data were already sent */
- stream_int_retnclose(&s->si[0], NULL);
+ http_reply_and_close(s, txn->status, NULL);
} else {
txn->status = 400;
- stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_400));
+ http_reply_and_close(s, txn->status, http_error_message(s, HTTP_ERR_400));
}
req->analysers = 0;
s->res.analysers = 0; /* we're in data phase, we want to abort both directions */
txn->req.msg_state = HTTP_MSG_ERROR;
if (txn->status) {
/* Note: we don't send any error if some data were already sent */
- stream_int_retnclose(&s->si[0], NULL);
+ http_reply_and_close(s, txn->status, NULL);
} else {
txn->status = 502;
- stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_502));
+ http_reply_and_close(s, txn->status, http_error_message(s, HTTP_ERR_502));
}
req->analysers = 0;
s->res.analysers = 0; /* we're in data phase, we want to abort both directions */
txn->status = 502;
s->si[1].flags |= SI_FL_NOLINGER;
channel_truncate(rep);
- stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_502));
+ http_reply_and_close(s, txn->status, http_error_message(s, HTTP_ERR_502));
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_PRXCOND;
txn->status = 502;
s->si[1].flags |= SI_FL_NOLINGER;
channel_truncate(rep);
- stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_502));
+ http_reply_and_close(s, txn->status, http_error_message(s, HTTP_ERR_502));
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_SRVCL;
txn->status = 504;
s->si[1].flags |= SI_FL_NOLINGER;
channel_truncate(rep);
- stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_504));
+ http_reply_and_close(s, txn->status, http_error_message(s, HTTP_ERR_504));
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_SRVTO;
txn->status = 400;
channel_truncate(rep);
- stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_400));
+ http_reply_and_close(s, txn->status, http_error_message(s, HTTP_ERR_400));
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_CLICL;
txn->status = 502;
s->si[1].flags |= SI_FL_NOLINGER;
channel_truncate(rep);
- stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_502));
+ http_reply_and_close(s, txn->status, http_error_message(s, HTTP_ERR_502));
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_SRVCL;
s->logs.level = 0;
s->res.flags &= ~CF_EXPECT_MORE; /* speed up sending a previous response */
channel_truncate(rep);
- stream_int_retnclose(&s->si[0], NULL);
+ http_reply_and_close(s, txn->status, NULL);
return 0;
}
s->logs.t_data = -1; /* was not a valid response */
s->si[1].flags |= SI_FL_NOLINGER;
channel_truncate(rep);
- stream_int_retnclose(&s->si[0], http_error_message(s, HTTP_ERR_502));
+ http_reply_and_close(s, txn->status, http_error_message(s, HTTP_ERR_502));
if (!(s->flags & SF_ERR_MASK))
s->flags |= SF_ERR_PRXCOND;
if (!(s->flags & SF_FINST_MASK))
txn->rsp.msg_state = HTTP_MSG_ERROR;
/* don't send any error message as we're in the body */
- stream_int_retnclose(&s->si[0], NULL);
+ http_reply_and_close(s, txn->status, NULL);
res->analysers = 0;
s->req.analysers = 0; /* we're in data phase, we want to abort both directions */
if (objt_server(s->target))
txn->rsp.msg_state = HTTP_MSG_ERROR;
/* don't send any error message as we're in the body */
- stream_int_retnclose(&s->si[0], NULL);
+ http_reply_and_close(s, txn->status, NULL);
res->analysers = 0;
s->req.analysers = 0; /* we're in data phase, we want to abort both directions */