mod_asis.c revision 36ef8f77bffe75d1aa327882be1b5bdbe2ff567a
/* 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 "apr_strings.h"
#include "ap_config.h"
#include "httpd.h"
#include "http_config.h"
#include "http_protocol.h"
#include "http_log.h"
#include "util_script.h"
#include "http_main.h"
#include "http_request.h"
#include "mod_core.h"
#define ASIS_MAGIC_TYPE "httpd/send-as-is"
static int asis_handler(request_rec *r)
{
conn_rec *c = r->connection;
apr_file_t *f = NULL;
const char *location;
return DECLINED;
if (r->method_number != M_GET)
return DECLINED;
"File does not exist: %s", r->filename);
return HTTP_NOT_FOUND;
}
"file permissions deny server access: %s", r->filename);
return HTTP_FORBIDDEN;
}
ap_scan_script_header_err(r, f, NULL);
apr_file_close(f);
/* Internal redirect -- fake-up a pseudo-request */
/* This redirect needs to be a GET no matter what the original
* method was.
*/
r->method_number = M_GET;
return OK;
}
if (!r->header_only) {
apr_bucket *b;
if (rv != APR_SUCCESS) {
"mod_asis: failed to find end-of-headers position "
"for %s", r->filename);
apr_file_close(f);
return HTTP_INTERNAL_SERVER_ERROR;
}
b = apr_bucket_eos_create(c->bucket_alloc);
if (rv != APR_SUCCESS) {
"mod_asis: ap_pass_brigade failed for file %s", r->filename);
return HTTP_INTERNAL_SERVER_ERROR;
}
}
else {
apr_file_close(f);
}
return OK;
}
static void register_hooks(apr_pool_t *p)
{
}
{
NULL, /* create per-directory config structure */
NULL, /* merge per-directory config structures */
NULL, /* create per-server config structure */
NULL, /* merge per-server config structures */
NULL, /* command apr_table_t */
register_hooks /* register hooks */
};