* University of Illinois, Urbana-Champaign.
*/
-#define CORE_PRIVATE
-#include "ap_config.h"
+#include "apr.h"
#include "apr_strings.h"
#include "apr_lib.h"
+#include "apr_fnmatch.h"
+#include "apr_thread_proc.h" /* for RLIMIT stuff */
+
+#if APR_HAVE_SYS_UIO_H
+#include <sys/uio.h> /* for iovec */
+#endif
+
+#define CORE_PRIVATE
+#include "ap_config.h"
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_log.h"
#include "rfc1413.h"
#include "util_md5.h"
-#include "apr_fnmatch.h"
#include "http_connection.h"
#include "ap_buckets.h"
#include "util_filter.h"
#include "util_ebcdic.h"
#include "mpm.h"
-#ifdef HAVE_NETDB_H
-#include <netdb.h>
-#endif
+
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
/* Code from Harald Hanche-Olsen <hanche@imf.unit.no> */
static apr_inline void do_double_reverse (conn_rec *conn)
{
- struct hostent *hptr;
+ apr_sockaddr_t *sa;
+ apr_status_t rv;
if (conn->double_reverse) {
/* already done */
conn->double_reverse = -1;
return;
}
- hptr = gethostbyname(conn->remote_host);
- if (hptr) {
- char **haddr;
-
- for (haddr = hptr->h_addr_list; *haddr; haddr++) {
- if (((struct in_addr *)(*haddr))->s_addr
- == conn->remote_addr.sin_addr.s_addr) {
- conn->double_reverse = 1;
- return;
- }
- }
+ rv = apr_getaddrinfo(&sa, conn->remote_host, APR_UNSPEC, 0, 0, conn->pool);
+ if (rv == APR_SUCCESS) {
+ while (sa) {
+ if (sa->ipaddr_len == conn->remote_addr->ipaddr_len &&
+ !memcmp(sa->ipaddr_ptr, conn->remote_addr->ipaddr_ptr,
+ sa->ipaddr_len)) {
+ conn->double_reverse = 1;
+ return;
+ }
+ sa = sa->next;
+ }
}
conn->double_reverse = -1;
}
&& conn->remote_host == NULL
&& (type == REMOTE_DOUBLE_REV
|| hostname_lookups != HOSTNAME_LOOKUP_OFF)) {
- if (apr_get_hostname(&conn->remote_host, APR_REMOTE, conn->client_socket)
- == APR_SUCCESS){
+ apr_sockaddr_t *remote_addr;
+
+ apr_get_sockaddr(&remote_addr, APR_REMOTE, conn->client_socket);
+ if (apr_getnameinfo(&conn->remote_host, remote_addr, 0) == APR_SUCCESS) {
ap_str_tolower(conn->remote_host);
if (hostname_lookups == HOSTNAME_LOOKUP_DOUBLE) {
* port of the actual socket.
*
* The DNS option to UseCanonicalName causes this routine to do a
- * reverse lookup on the local IP address of the connectiona and use
+ * reverse lookup on the local IP address of the connection and use
* that for the ServerName. This makes its value more reliable while
* at the same time allowing Demon's magic virtual hosting to work.
* The assumption is that DNS lookups are sufficiently quick...
}
if (d->use_canonical_name == USE_CANONICAL_NAME_DNS) {
if (conn->local_host == NULL) {
- if (apr_get_hostname(&conn->local_host, APR_LOCAL, conn->client_socket) != APR_SUCCESS)
+ apr_sockaddr_t *local_addr;
+
+ apr_get_sockaddr(&local_addr, APR_LOCAL, conn->client_socket);
+ if (apr_getnameinfo(&conn->local_host, local_addr, 0) != APR_SUCCESS)
conn->local_host = apr_pstrdup(conn->pool, r->server->server_hostname);
- else
+ else {
ap_str_tolower(conn->local_host);
+ }
}
return conn->local_host;
}
}
arg = ap_os_canonical_filename(cmd->pool, arg);
- if (/* TODO: ap_configtestonly && ap_docrootcheck && */ !ap_is_directory(arg)) {
+ if (/* TODO: ap_configtestonly && ap_docrootcheck && */ !ap_is_directory(cmd->pool, arg)) {
if (cmd->server->is_virtual) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL,
+ ap_log_perror(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, cmd->pool,
"Warning: DocumentRoot [%s] does not exist",
arg);
}
arg = ap_os_canonical_filename(cmd->pool, arg);
- if (!ap_is_directory(arg)) {
+ if (!ap_is_directory(cmd->pool, arg)) {
return "ServerRoot must be a valid directory";
}
ap_server_root = arg;
}
#endif
-static apr_status_t writev_it_all(apr_socket_t *s, struct iovec *vec, int nvec,
+static apr_status_t writev_it_all(apr_socket_t *s,
+ struct iovec *vec, int nvec,
apr_size_t len, apr_size_t *nbytes)
{
apr_size_t bytes_written = 0;
&timeout) == APR_SUCCESS) &&
timeout > 0); /* socket must be in timeout mode */
do {
- apr_ssize_t tmplen = file_bytes_left;
+ apr_size_t tmplen = file_bytes_left;
rv = apr_sendfile(c->client_socket, fd, hdtr, &file_offset, &tmplen,
flags);
++hdtr->headers;
}
else {
+ char *iov_base = (char *)hdtr->headers[0].iov_base;
+
hdtr->headers[0].iov_len -= tmplen;
- (char *) hdtr->headers[0].iov_base += tmplen;
+ iov_base += tmplen;
+ hdtr->headers[0].iov_base = iov_base;
tmplen = 0;
}
}
++hdtr->trailers;
}
else {
+ char *iov_base = (char *)hdtr->trailers[0].iov_base;
+
hdtr->trailers[0].iov_len -= tmplen;
- (char *)hdtr->trailers[0].iov_base += tmplen;
+ iov_base += tmplen;
+ hdtr->trailers[0].iov_base = iov_base;
tmplen = 0;
}
}
{
ap_bucket_brigade *bb;
ap_bucket *e;
- core_dir_config *d =
- (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module);
+ core_dir_config *d;
int errstatus;
apr_file_t *fd = NULL;
apr_status_t status;
* support fairly closely (unlike 1.3, we don't handle computing md5
* when the charset is translated).
*/
- int bld_content_md5 =
- (d->content_md5 & 1) && r->output_filters->frec->ftype != AP_FTYPE_CONTENT;
+ int bld_content_md5;
+
+ /*
+ * The old way of doing handlers meant that this handler would
+ * match literally anything - this way will require handler to
+ * have a / in the middle, which probably captures the original
+ * intent, but may cause problems at first - Ben 7th Jan 01
+ */
+ if(strcmp(r->handler,"default-handler")
+ && ap_strcmp_match(r->handler,"*/*"))
+ return DECLINED;
+
+ d = (core_dir_config *)ap_get_module_config(r->per_dir_config,
+ &core_module);
+ bld_content_md5 = (d->content_md5 & 1)
+ && r->output_filters->frec->ftype != AP_FTYPE_CONTENT;
ap_allow_methods(r, MERGE_ALLOW, "GET", "OPTIONS", "POST", NULL);
ap_set_last_modified(r);
ap_set_etag(r);
apr_table_setn(r->headers_out, "Accept-Ranges", "bytes");
- ap_set_content_length(r, r->finfo.size);
+ ap_set_content_length(r, r->finfo.size);
if ((errstatus = ap_meets_conditions(r)) != OK) {
apr_close(fd);
return errstatus;
return APR_SUCCESS;
}
-static const handler_rec core_handlers[] = {
-{ "*/*", default_handler },
-{ "default-handler", default_handler },
-{ NULL, NULL }
-};
-
static void core_pre_config(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp)
{
ap_init_bucket_types(pconf);
ap_hook_http_method(core_method,NULL,NULL,AP_HOOK_REALLY_LAST);
ap_hook_default_port(core_port,NULL,NULL,AP_HOOK_REALLY_LAST);
ap_hook_open_logs(core_open_logs,NULL,NULL,AP_HOOK_MIDDLE);
+ ap_hook_handler(default_handler,NULL,NULL,AP_HOOK_REALLY_LAST);
/* FIXME: I suspect we can eliminate the need for these - Ben */
ap_hook_type_checker(do_nothing,NULL,NULL,AP_HOOK_REALLY_LAST);
ap_hook_access_checker(do_nothing,NULL,NULL,AP_HOOK_REALLY_LAST);
create_core_server_config, /* create per-server config structure */
merge_core_server_configs, /* merge per-server config structures */
core_cmds, /* command apr_table_t */
- core_handlers, /* handlers */
register_hooks /* register hooks */
};