mod_asis.c revision 04891cf70e0bfc38bfb027541dc821f04c754ff7
/* Copyright 2000-2004 Apache Software Foundation
*
* Licensed 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;
}
/* APR_HAS_LARGE_FILES issue; must split into mutiple buckets,
* no greater than MAX(apr_size_t), and more granular than that
*/
r->pool, c->bucket_alloc);
while (fsize > AP_MAX_SENDFILE) {
apr_bucket_copy(b, &b);
b->start += AP_MAX_SENDFILE;
fsize -= AP_MAX_SENDFILE;
}
}
else
#endif
r->pool, c->bucket_alloc);
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 */
};