summaryrefslogtreecommitdiffstats
path: root/modules/echo/mod_echo.c
diff options
context:
space:
mode:
authorRyan Bloom <rbb@apache.org>2001-06-06 23:28:20 +0200
committerRyan Bloom <rbb@apache.org>2001-06-06 23:28:20 +0200
commitf4fb42920951d9bc7b2ec480d618112834a1d92a (patch)
treea5502aab75b0614d32d35d8c1d663bad8d51a593 /modules/echo/mod_echo.c
parentget rid of util_date.c/util_date.h and associated test program (diff)
downloadapache2-f4fb42920951d9bc7b2ec480d618112834a1d92a.tar.xz
apache2-f4fb42920951d9bc7b2ec480d618112834a1d92a.zip
Make mod_echo use filters for all communication with clients.
Submitted by: Ryan Morgan <rmorgan@covalent.net> git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89279 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/echo/mod_echo.c')
-rw-r--r--modules/echo/mod_echo.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/modules/echo/mod_echo.c b/modules/echo/mod_echo.c
index f182123213..ee3ca35f11 100644
--- a/modules/echo/mod_echo.c
+++ b/modules/echo/mod_echo.c
@@ -62,6 +62,8 @@
#include "http_config.h"
#include "http_connection.h"
+#include "apr_buckets.h"
+#include "util_filter.h"
AP_DECLARE_DATA module echo_module;
typedef struct {
@@ -88,26 +90,32 @@ static const char *echo_on(cmd_parms *cmd, void *dummy, int arg)
static int process_echo_connection(conn_rec *c)
{
- char buf[1024];
+ apr_bucket_brigade *bb;
+ apr_bucket *b;
+ apr_status_t rv;
+ int zero = 0;
EchoConfig *pConfig = ap_get_module_config(c->base_server->module_config,
&echo_module);
if (!pConfig->bEnabled) {
return DECLINED;
}
+
+ bb = apr_brigade_create(c->pool);
for ( ; ; ) {
- apr_ssize_t r, w;
- r = sizeof(buf);
- apr_recv(c->client_socket, buf, &r);
- if (r <= 0) {
+ /* Get a single line of input from the client */
+ if ((rv = ap_get_brigade(c->input_filters, bb,
+ AP_MODE_BLOCKING, &zero) != APR_SUCCESS ||
+ APR_BRIGADE_EMPTY(bb))) {
+ apr_brigade_destroy(bb);
break;
}
- w = r;
- apr_send(c->client_socket, buf, &w);
- if (w != r) {
- break;
- }
+
+ /* Make sure the data is flushed to the client */
+ b = apr_bucket_flush_create();
+ APR_BRIGADE_INSERT_TAIL(bb, b);
+ ap_pass_brigade(c->output_filters, bb);
}
return OK;
}