[MEDIUM] buffers: add BF_EMPTY and BF_FULL to remove dependency on req/rep->l

It is not always convenient to run checks on req->l in functions to
check if a buffer is empty or full. Now the stream_sock functions
set flags BF_EMPTY and BF_FULL according to the buffer contents. Of
course, functions which touch the buffer contents adjust the flags
too.
diff --git a/src/senddata.c b/src/senddata.c
index 33fe548..6bc5915 100644
--- a/src/senddata.c
+++ b/src/senddata.c
@@ -51,13 +51,13 @@
 	EV_FD_CLR(s->cli_fd, DIR_RD);
 	EV_FD_SET(s->cli_fd, DIR_WR);
 	buffer_shutr(s->req);
+	buffer_flush(s->req);
 	s->rep->wex = tick_add_ifset(now_ms, s->rep->wto);
 	s->rep->flags |= BF_MAY_FORWARD;
 	s->cli_state = CL_STSHUTR; // FIXME: still used by unix sockets
 	buffer_flush(s->rep);
 	if (msg && msg->len)
 		buffer_write(s->rep, msg->str, msg->len);
-	s->req->l = 0;
 }
 
 
@@ -69,10 +69,10 @@
  */
 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);
-	s->req->l = 0;
 }
 
 /*