summaryrefslogtreecommitdiffstats
path: root/modules/echo
diff options
context:
space:
mode:
authorBen Laurie <ben@apache.org>1999-07-23 20:52:29 +0200
committerBen Laurie <ben@apache.org>1999-07-23 20:52:29 +0200
commit8b2e728bda846016ceb584a7e619ca7fb3df54d3 (patch)
tree3781dbf5a10afaa8be392d425096ff0f097e6aea /modules/echo
parentActually, we should always close the connection when it is finished. (diff)
downloadapache2-8b2e728bda846016ceb584a7e619ca7fb3df54d3.tar.xz
apache2-8b2e728bda846016ceb584a7e619ca7fb3df54d3.zip
Support for echo protocol, to show how multiprotocol support works.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@83489 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/echo')
-rw-r--r--modules/echo/mod_echo.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/modules/echo/mod_echo.c b/modules/echo/mod_echo.c
new file mode 100644
index 0000000000..210cfa708d
--- /dev/null
+++ b/modules/echo/mod_echo.c
@@ -0,0 +1,82 @@
+#include "httpd.h"
+#include "http_config.h"
+#include "http_connection.h"
+
+API_VAR_EXPORT module echo_module;
+
+typedef struct
+ {
+ int bEnabled;
+ } EchoConfig;
+
+static void *create_echo_server_config(pool *p,server_rec *s)
+ {
+ EchoConfig *pConfig=ap_pcalloc(p,sizeof *pConfig);
+
+ pConfig->bEnabled=0;
+
+ return pConfig;
+ }
+
+static const char *echo_on(cmd_parms *cmd, void *dummy, char *arg)
+ {
+ EchoConfig *pConfig=ap_get_module_config(cmd->server->module_config,
+ &echo_module);
+ pConfig->bEnabled=1;
+
+ return NULL;
+ }
+
+static int process_echo_connection(conn_rec *c)
+ {
+ char buf[1024];
+ EchoConfig *pConfig=ap_get_module_config(c->base_server->module_config,
+ &echo_module);
+
+ if(!pConfig->bEnabled)
+ return DECLINED;
+
+ for( ; ; )
+ {
+ int w;
+ int r=ap_bread(c->client,buf,sizeof buf);
+ if(r <= 0)
+ break;
+ w=ap_bwrite(c->client,buf,r);
+ if(w != r)
+ break;
+ ap_bflush(c->client);
+ }
+ return OK;
+ }
+
+static const command_rec echo_cmds[] = {
+{ "ProtocolEcho", echo_on, NULL, RSRC_CONF, RAW_ARGS,
+ "Run an echo server on this host" },
+{ NULL }
+};
+
+static void register_hooks()
+ {
+ ap_hook_process_connection(process_echo_connection,NULL,NULL,HOOK_MIDDLE);
+ }
+
+API_VAR_EXPORT module echo_module = {
+ STANDARD20_MODULE_STUFF,
+ NULL, /* pre_command_line */
+ NULL, /* pre_config */
+ NULL, /* post_config */
+ NULL, /* open_logs */
+ NULL, /* child_init */
+ NULL, /* create per-directory config structure */
+ NULL, /* merge per-directory config structures */
+ create_echo_server_config, /* create per-server config structure */
+ NULL, /* merge per-server config structures */
+ echo_cmds, /* command table */
+ NULL, /* handlers */
+ NULL, /* check auth */
+ NULL, /* check access */
+ NULL, /* type_checker */
+ NULL, /* pre-run fixups */
+ register_hooks /* register hooks */
+};