mod_echo.c revision 3f4d7fdb598d64d80ab8656852276246f2f3b502
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding/* ====================================================================
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * The Apache Software License, Version 1.1
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * reserved.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Redistribution and use in source and binary forms, with or without
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * modification, are permitted provided that the following conditions
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * 1. Redistributions of source code must retain the above copyright
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * notice, this list of conditions and the following disclaimer.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * 2. Redistributions in binary form must reproduce the above copyright
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * notice, this list of conditions and the following disclaimer in
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * the documentation and/or other materials provided with the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * distribution.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * 3. The end-user documentation included with the redistribution,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * if any, must include the following acknowledgment:
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * "This product includes software developed by the
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Apache Software Foundation (http://www.apache.org/)."
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Alternately, this acknowledgment may appear in the software itself,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * if and wherever such third-party acknowledgments normally appear.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * 4. The names "Apache" and "Apache Software Foundation" must
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * not be used to endorse or promote products derived from this
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * software without prior written permission. For written
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * permission, please contact apache@apache.org.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * 5. Products derived from this software may not be called "Apache",
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * nor may "Apache" appear in their name, without prior written
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * permission of the Apache Software Foundation.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * SUCH DAMAGE.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * ====================================================================
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * This software consists of voluntary contributions made by many
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * individuals on behalf of the Apache Software Foundation. For more
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * information on the Apache Software Foundation, please see
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * Portions of this software are based upon public domain software
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * originally written at the National Center for Supercomputing Applications,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding * University of Illinois, Urbana-Champaign.
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingtypedef struct {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingstatic void *create_echo_server_config(apr_pool_t *p, server_rec *s)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding EchoConfig *pConfig = apr_pcalloc(p, sizeof *pConfig);
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fieldingstatic const char *echo_on(cmd_parms *cmd, void *dummy, int arg)
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding EchoConfig *pConfig = ap_get_module_config(cmd->server->module_config,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding EchoConfig *pConfig = ap_get_module_config(c->base_server->module_config,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding for ( ; ; ) {
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /* Get a single line of input from the client */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding /* Make sure the data is flushed to the client */
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding AP_INIT_FLAG("ProtocolEcho", echo_on, NULL, RSRC_CONF,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding "Run an echo server on this host"),
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding ap_hook_process_connection(process_echo_connection, NULL, NULL,
09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1fielding create_echo_server_config, /* create per-server config structure */