diff --git a/include/proto/proto_http.h b/include/proto/proto_http.h index 0fcbea65c..e291eae3d 100644 --- a/include/proto/proto_http.h +++ b/include/proto/proto_http.h @@ -66,7 +66,6 @@ int process_request(struct session *t); int process_response(struct session *t); void client_retnclose(struct session *s, const struct chunk *msg); -void client_return(struct session *s, const struct chunk *msg); void srv_close_with_err(struct session *t, int err, int finst, int status, const struct chunk *msg); diff --git a/include/proto/senddata.h b/include/proto/senddata.h index 5cb5b6441..eb6580371 100644 --- a/include/proto/senddata.h +++ b/include/proto/senddata.h @@ -28,7 +28,6 @@ #include void client_retnclose(struct session *s, const struct chunk *msg); -void client_return(struct session *s, const struct chunk *msg); #endif /* _PROTO_SENDDATA_H */ diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h index 9967a6e33..bbdcecc71 100644 --- a/include/proto/stream_interface.h +++ b/include/proto/stream_interface.h @@ -3,7 +3,7 @@ This file contains stream_interface function prototypes Copyright (C) 2000-2008 Willy Tarreau - w@1wt.eu - + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, version 2.1 @@ -31,6 +31,7 @@ /* main event functions used to move data between sockets and buffers */ void stream_int_check_timeouts(struct stream_interface *si); void stream_int_report_error(struct stream_interface *si); +void stream_int_return(struct stream_interface *si, const struct chunk *msg); #endif /* _PROTO_STREAM_INTERFACE_H */ diff --git a/src/proto_http.c b/src/proto_http.c index b14322eb9..e3216415a 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -549,7 +549,7 @@ void srv_close_with_err(struct session *t, int err, int finst, if (status > 0 && msg) { t->txn.status = status; if (t->fe->mode == PR_MODE_HTTP) - client_return(t, msg); + stream_int_return(t->rep->cons, msg); } if (!(t->flags & SN_ERR_MASK)) t->flags |= err; @@ -2675,7 +2675,7 @@ int process_response(struct session *t) t->be->failed_resp++; rep->analysers = 0; txn->status = 502; - client_return(t, error_message(t, HTTP_ERR_502)); + stream_int_return(rep->cons, error_message(t, HTTP_ERR_502)); if (!(t->flags & SN_ERR_MASK)) t->flags |= SN_ERR_PRXCOND; if (!(t->flags & SN_FINST_MASK)) @@ -2704,7 +2704,7 @@ int process_response(struct session *t) //t->be->failed_resp++; rep->analysers = 0; txn->status = 502; - client_return(t, error_message(t, HTTP_ERR_502)); + stream_int_return(rep->cons, error_message(t, HTTP_ERR_502)); if (!(t->flags & SN_ERR_MASK)) t->flags |= SN_ERR_SRVCL; if (!(t->flags & SN_FINST_MASK)) @@ -2729,7 +2729,7 @@ int process_response(struct session *t) t->be->failed_resp++; rep->analysers = 0; txn->status = 504; - client_return(t, error_message(t, HTTP_ERR_504)); + stream_int_return(rep->cons, error_message(t, HTTP_ERR_504)); if (!(t->flags & SN_ERR_MASK)) t->flags |= SN_ERR_SRVTO; if (!(t->flags & SN_FINST_MASK)) @@ -2753,7 +2753,7 @@ int process_response(struct session *t) t->be->failed_resp++; rep->analysers = 0; txn->status = 502; - client_return(t, error_message(t, HTTP_ERR_502)); + stream_int_return(rep->cons, error_message(t, HTTP_ERR_502)); if (!(t->flags & SN_ERR_MASK)) t->flags |= SN_ERR_SRVCL; if (!(t->flags & SN_FINST_MASK)) @@ -2853,7 +2853,7 @@ int process_response(struct session *t) //req->cons->state = SI_ST_CLO; rep->analysers = 0; txn->status = 502; - client_return(t, error_message(t, HTTP_ERR_502)); + stream_int_return(rep->cons, error_message(t, HTTP_ERR_502)); if (!(t->flags & SN_ERR_MASK)) t->flags |= SN_ERR_PRXCOND; if (!(t->flags & SN_FINST_MASK)) diff --git a/src/senddata.c b/src/senddata.c index 5d4b8a6be..fd1d8389b 100644 --- a/src/senddata.c +++ b/src/senddata.c @@ -63,21 +63,6 @@ void client_retnclose(struct session *s, const struct chunk *msg) buffer_write_ena(s->rep); } - -/* - * returns a message into the rep buffer, and flushes the req buffer. - * The reply buffer doesn't need to be empty before this. The message - * is contained in a "chunk". If it is null, then an empty message is - * used. - */ -void client_return(struct session *s, const struct chunk *msg) -{ - buffer_flush(s->req); - buffer_flush(s->rep); - if (msg && msg->len) - buffer_write(s->rep, msg->str, msg->len); -} - /* * Local variables: * c-indent-level: 8 diff --git a/src/stream_interface.c b/src/stream_interface.c index debdaa71f..96087906f 100644 --- a/src/stream_interface.c +++ b/src/stream_interface.c @@ -58,6 +58,19 @@ void stream_int_report_error(struct stream_interface *si) si->ib->flags |= BF_READ_ERROR; } +/* + * Returns a message into the output buffer, and flushes the input buffer. The + * output buffer doesn't need to be empty before this. The message is contained + * in a "chunk". If it is null, then an empty message is used. + */ +void stream_int_return(struct stream_interface *si, const struct chunk *msg) +{ + buffer_flush(si->ib); + buffer_flush(si->ob); + if (msg && msg->len) + buffer_write(si->ob, msg->str, msg->len); +} + /* * Local variables: * c-indent-level: 8