mod_echo.c revision d6e81217d873dc3b87fc4ffa5fbac2fad4191a15
/* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "ap_config.h"
#include "ap_mmn.h"
#include "httpd.h"
#include "http_config.h"
#include "http_connection.h"
#include "http_core.h"
#include "http_log.h"
#include "apr_buckets.h"
#include "apr_strings.h"
#include "util_filter.h"
#include "scoreboard.h"
typedef struct {
int bEnabled;
} EchoConfig;
{
return pConfig;
}
{
&echo_module);
return NULL;
}
{
apr_bucket *b;
apr_size_t readbytes = 0;
if (bufflen--)
/* compensate for NULL */
*buff = '\0';
else
return APR_EGENERAL;
if (APR_BRIGADE_EMPTY(bbIn))
return APR_EGENERAL;
b = APR_BRIGADE_FIRST(bbIn);
const char *pos;
const char *str;
!= APR_SUCCESS)
return rv;
b = APR_BUCKET_NEXT(b);
}
return APR_SUCCESS;
}
{
if (!ap_extended_status)
return old_status;
/* initial pass only, please - in the name of efficiency */
if (c) {
/* Deliberate trailing space - filling in string on WRITE passes */
}
/* each subsequent WRITE pass, let's update what we echoed */
if (last_echoed) {
}
return old_status;
}
static int process_echo_connection(conn_rec *c)
{
apr_bucket *b;
&echo_module);
return DECLINED;
}
for ( ; ; ) {
/* Get a single line of input from the client */
APR_BLOCK_READ, 0)) != APR_SUCCESS)) {
"ProtocolEcho: Failure reading from %s",
c->remote_ip);
break;
}
/* Something horribly wrong happened. Someone didn't block! */
if (APR_BRIGADE_EMPTY(bb)) {
"ProtocolEcho: Error - read empty brigade from %s!",
c->remote_ip);
break;
}
if (!csd) {
}
/* Make sure the data is flushed to the client */
b = apr_bucket_flush_create(c->bucket_alloc);
if (rv != APR_SUCCESS) {
"ProtocolEcho: Failure writing to %s",
c->remote_ip);
break;
}
/* Announce our intent to loop */
}
return OK;
}
static const command_rec echo_cmds[] =
{
"Run an echo server on this host"),
{ NULL }
};
static void register_hooks(apr_pool_t *p)
{
}
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 apr_table_t */
register_hooks /* register hooks */
};