diff -u7 -r orig-httpd-2.0.43/include/http_core.h httpd-2.0.43/include/http_core.h --- orig-httpd-2.0.43/include/http_core.h Sat May 11 18:24:29 2002 +++ httpd-2.0.43/include/http_core.h Sat Oct 26 16:36:03 2002 @@ -146,17 +146,17 @@ * @param r The current request * @return the overrides bitmask * @deffunc int ap_allow_overrides(request_rec *r) */ AP_DECLARE(int) ap_allow_overrides(request_rec *r); /** - * Retrieve the value of the DefaultType directive, or text/plain if not set + * Retrieve the value of the DefaultType directive * @param r The current request - * @return The default type + * @return The default type or NULL if not set * @deffunc const char *ap_default_type(request_rec *r) */ AP_DECLARE(const char *) ap_default_type(request_rec *r); /** * Retrieve the document root for this server * @param r The current request diff -u7 -r orig-httpd-2.0.43/include/http_protocol.h httpd-2.0.43/include/http_protocol.h --- orig-httpd-2.0.43/include/http_protocol.h Thu Jul 11 14:53:04 2002 +++ httpd-2.0.43/include/http_protocol.h Sat Oct 26 16:38:08 2002 @@ -161,14 +161,15 @@ */ AP_DECLARE(apr_time_t) ap_rationalize_mtime(request_rec *r, apr_time_t mtime); /** * Build the content-type that should be sent to the client from the * content-type specified. The following rules are followed: * - if type is NULL, type is set to ap_default_type(r) + * - if type is still NULL, return NULL * - if charset adding is disabled, stop processing and return type. * - then, if there are no parameters on type, add the default charset * - return type * @param r The current request * @return The content-type * @deffunc const char *ap_make_content_type(request_rec *r, const char *type); */ diff -u7 -r orig-httpd-2.0.43/include/httpd.h httpd-2.0.43/include/httpd.h --- orig-httpd-2.0.43/include/httpd.h Mon Jul 1 12:49:53 2002 +++ httpd-2.0.43/include/httpd.h Sat Oct 26 16:35:05 2002 @@ -240,24 +240,14 @@ /* ------------------ stuff that modules are allowed to look at ----------- */ /** Define this to be what your HTML directory content files are called */ #ifndef AP_DEFAULT_INDEX #define AP_DEFAULT_INDEX "index.html" #endif - -/** - * Define this to be what type you'd like returned for files with unknown - * suffixes. - * @warning MUST be all lower case. - */ -#ifndef DEFAULT_CONTENT_TYPE -#define DEFAULT_CONTENT_TYPE "text/plain" -#endif - /** The name of the MIME types file */ #ifndef AP_TYPES_CONFIG_FILE #define AP_TYPES_CONFIG_FILE "conf/mime.types" #endif /* * Define the HTML doctype strings centrally. diff -u7 -r orig-httpd-2.0.43/modules/experimental/mod_charset_lite.c httpd-2.0.43/modules/experimental/mod_charset_lite.c --- orig-httpd-2.0.43/modules/experimental/mod_charset_lite.c Fri Jul 19 03:47:55 2002 +++ httpd-2.0.43/modules/experimental/mod_charset_lite.c Sat Oct 26 17:16:57 2002 @@ -273,43 +273,44 @@ if (!strncmp(r->filename, "redirect:", 9)) return DECLINED; if (!strncmp(r->filename, "gone:", 5)) return DECLINED; if (!strncmp(r->filename, "passthrough:", 12)) return DECLINED; if (!strncmp(r->filename, "forbidden:", 10)) return DECLINED; mime_type = r->content_type ? r->content_type : ap_default_type(r); - /* If mime type isn't text or message, bail out. + /* If mime type isn't set or is not text or message, bail out. */ /* XXX When we handle translation of the request body, watch out here as * 1.3 allowed additional mime types: multipart and * application/x-www-form-urlencoded */ - if (strncasecmp(mime_type, "text/", 5) && + if (!mime_type || + (strncasecmp(mime_type, "text/", 5) && #if APR_CHARSET_EBCDIC /* On an EBCDIC machine, be willing to translate mod_autoindex- * generated output. Otherwise, it doesn't look too cool. * * XXX This isn't a perfect fix because this doesn't trigger us * to convert from the charset of the source code to ASCII. The * general solution seems to be to allow a generator to set an * indicator in the r specifying that the body is coded in the * implementation character set (i.e., the charset of the source * code). This would get several different types of documents * translated properly: mod_autoindex output, mod_status output, * mod_info output, hard-coded error documents, etc. */ - strcmp(mime_type, DIR_MAGIC_TYPE) && + strcmp(mime_type, DIR_MAGIC_TYPE) && #endif - strncasecmp(mime_type, "message/", 8)) { + strncasecmp(mime_type, "message/", 8))) { if (dc->debug >= DBGLVL_GORY) { ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "mime type is %s; no translation selected", - mime_type); + mime_type ? mime_type : "not present"); } return DECLINED; } if (dc->debug >= DBGLVL_GORY) { ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, "charset_source: %s charset_default: %s", diff -u7 -r orig-httpd-2.0.43/modules/experimental/mod_disk_cache.c httpd-2.0.43/modules/experimental/mod_disk_cache.c --- orig-httpd-2.0.43/modules/experimental/mod_disk_cache.c Tue Sep 17 00:37:39 2002 +++ httpd-2.0.43/modules/experimental/mod_disk_cache.c Sat Oct 26 16:56:28 2002 @@ -467,17 +467,19 @@ r->headers_out = apr_table_make(r->pool, 20); } /* * Call routine to read the header lines/status line */ ap_scan_script_header_err(r, dobj->hfd, NULL); - - apr_table_setn(r->headers_out, "Content-Type", - ap_make_content_type(r, r->content_type)); + + const char * content_type = ap_make_content_type(r, r->content_type); + if (content_type) { + apr_table_setn(r->headers_out, "Content-Type", content_type); + } rv = apr_file_gets(&urlbuff[0], urllen, dobj->hfd); /* Read status */ if (rv != APR_SUCCESS) { /* XXX log message */ return rv; } @@ -579,16 +581,18 @@ } buf = apr_pstrcat(r->pool, CRLF, NULL); amt = strlen(buf); apr_file_write(hfd, buf, &amt); /* This case only occurs when the content is generated locally */ if (!apr_table_get(r->headers_out, "Content-Type") && r->content_type) { - apr_table_setn(r->headers_out, "Content-Type", - ap_make_content_type(r, r->content_type)); + const char * content_type = ap_make_content_type(r, r->content_type); + if (content_type) { + apr_table_setn(r->headers_out, "Content-Type", content_type); + } } } sprintf(statusbuf,"%d", r->status); buf = apr_pstrcat(r->pool, statusbuf, CRLF, NULL); amt = strlen(buf); apr_file_write(hfd, buf, &amt); diff -u7 -r orig-httpd-2.0.43/modules/http/http_protocol.c httpd-2.0.43/modules/http/http_protocol.c --- orig-httpd-2.0.43/modules/http/http_protocol.c Sat Sep 21 19:05:08 2002 +++ httpd-2.0.43/modules/http/http_protocol.c Sat Oct 26 18:23:02 2002 @@ -1113,14 +1113,19 @@ #if APR_CHARSET_EBCDIC char *headfield; apr_size_t len; apr_size_t name_len; apr_size_t val_len; char *next; + if (!fieldval) { + /* Header not set to anything useful; just skip it */ + return 1; + } + name_len = strlen(fieldname); val_len = strlen(fieldval); len = name_len + val_len + 4; /* 4 for ": " plus CRLF */ headfield = (char *)apr_palloc(h->pool, len + 1); memcpy(headfield, fieldname, name_len); next = headfield + name_len; *next++ = ':'; @@ -1131,14 +1136,19 @@ *next++ = LF; *next = 0; ap_xlate_proto_to_ascii(headfield, len); apr_brigade_write(h->bb, NULL, NULL, headfield, len); #else struct iovec vec[4]; struct iovec *v = vec; + if (!fieldval) { + /* Header not set to anything useful; just skip it */ + return 1; + } + v->iov_base = (void *)fieldname; v->iov_len = strlen(fieldname); v++; v->iov_base = ": "; v->iov_len = sizeof(": ") - 1; v++; v->iov_base = (void *)fieldval; @@ -1495,15 +1505,16 @@ conn_rec *c = r->connection; const char *clheader; const char *protocol; apr_bucket *e; apr_bucket_brigade *b2; header_struct h; header_filter_ctx *ctx = f->ctx; - + const char * content_type; + AP_DEBUG_ASSERT(!r->main); if (r->header_only) { if (!ctx) { ctx = f->ctx = apr_pcalloc(r->pool, sizeof(header_filter_ctx)); } else if (ctx->headers_sent) { @@ -1567,16 +1578,18 @@ ap_set_keepalive(r); if (r->chunked) { apr_table_mergen(r->headers_out, "Transfer-Encoding", "chunked"); apr_table_unset(r->headers_out, "Content-Length"); } - apr_table_setn(r->headers_out, "Content-Type", - ap_make_content_type(r, r->content_type)); + content_type = ap_make_content_type(r, r->content_type); + if (content_type) { + apr_table_setn(r->headers_out, "Content-Type", content_type); + } if (r->content_encoding) { apr_table_setn(r->headers_out, "Content-Encoding", r->content_encoding); } if (!apr_is_empty_array(r->content_languages)) { @@ -2843,16 +2856,16 @@ ap_set_content_type(r, apr_pstrcat(r->pool, "multipart", use_range_x(r) ? "/x-" : "/", "byteranges; boundary=", ctx->boundary, NULL)); ctx->bound_head = apr_pstrcat(r->pool, CRLF "--", ctx->boundary, - CRLF "Content-type: ", - orig_ct, + orig_ct ? CRLF "Content-type: " : "", + orig_ct ? orig_ct : "", CRLF "Content-range: bytes ", NULL); ap_xlate_proto_to_ascii(ctx->bound_head, strlen(ctx->bound_head)); } } /* We can't actually deal with byte-ranges until we have the whole brigade diff -u7 -r orig-httpd-2.0.43/modules/mappers/mod_negotiation.c httpd-2.0.43/modules/mappers/mod_negotiation.c --- orig-httpd-2.0.43/modules/mappers/mod_negotiation.c Fri Aug 9 14:21:57 2002 +++ httpd-2.0.43/modules/mappers/mod_negotiation.c Sat Oct 26 18:20:28 2002 @@ -1179,14 +1179,16 @@ /* * ###: be warned, the _default_ content type is already * picked up here! If we failed the subrequest, or don't * know what we are serving, then continue. */ if (sub_req->status != HTTP_OK || (!sub_req->content_type)) { + /* XXX This seems to be a problem if default types are + allowed to be null... */ ap_destroy_sub_req(sub_req); continue; } /* If it's a map file, we use that instead of the map * we're building... */ @@ -1210,16 +1212,18 @@ if (sub_req->content_encoding) { mime_info.content_encoding = sub_req->content_encoding; } if (sub_req->content_languages) { mime_info.content_languages = sub_req->content_languages; } - get_entry(neg->pool, &accept_info, sub_req->content_type); - set_mime_fields(&mime_info, &accept_info); + if (sub_req->content_type) { + get_entry(neg->pool, &accept_info, sub_req->content_type); + set_mime_fields(&mime_info, &accept_info); + } new_var = apr_array_push(neg->avail_vars); memcpy(new_var, (void *) &mime_info, sizeof(var_rec)); neg->count_multiviews_variants++; clean_var_rec(&mime_info); diff -u7 -r orig-httpd-2.0.43/modules/metadata/mod_expires.c httpd-2.0.43/modules/metadata/mod_expires.c --- orig-httpd-2.0.43/modules/metadata/mod_expires.c Wed Jul 17 11:08:53 2002 +++ httpd-2.0.43/modules/metadata/mod_expires.c Sat Oct 26 17:32:41 2002 @@ -447,14 +447,16 @@ * with a NULL key will SEGV us * * I still don't know *why* r->content_type would ever be NULL, this * is possibly a result of fixups being called in many different * places. Fixups is probably the wrong place to be doing all this * work... Bah. * + * XXX r->content_type could be null if there is no DefaultType directive. + * * Changed as of 08.Jun.96 don't DECLINE, look for an ExpiresDefault. */ if (r->content_type == NULL) code = NULL; else code = (char *) apr_table_get(conf->expiresbytype, ap_field_noparam(r->pool, r->content_type)); diff -u7 -r orig-httpd-2.0.43/modules/metadata/mod_mime_magic.c httpd-2.0.43/modules/metadata/mod_mime_magic.c --- orig-httpd-2.0.43/modules/metadata/mod_mime_magic.c Sat Jun 29 23:30:41 2002 +++ httpd-2.0.43/modules/metadata/mod_mime_magic.c Sat Oct 26 17:34:50 2002 @@ -842,16 +842,15 @@ /* XXX: this could be done at config time I'm sure... but I'm * confused by all this magic_rsl stuff. -djg */ ap_str_tolower(tmp); r->content_encoding = tmp; } /* detect memory allocation or other errors */ - if (!r->content_type || - (state == rsl_encoding && !r->content_encoding)) { + if (state == rsl_encoding && !r->content_encoding) { ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, MODNAME ": unexpected state %d; could be caused by bad " "data in magic file", state); return HTTP_INTERNAL_SERVER_ERROR; } diff -u7 -r orig-httpd-2.0.43/modules/proxy/proxy_ftp.c httpd-2.0.43/modules/proxy/proxy_ftp.c --- orig-httpd-2.0.43/modules/proxy/proxy_ftp.c Sun Aug 18 16:01:06 2002 +++ httpd-2.0.43/modules/proxy/proxy_ftp.c Sat Oct 26 17:36:28 2002 @@ -1731,15 +1731,16 @@ apr_table_setn(r->headers_out, "Content-Length", size); ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, "proxy: FTP: Content-Length set to %s", size); } } apr_table_setn(r->headers_out, "Content-Type", r->content_type); ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, - "proxy: FTP: Content-Type set to %s", r->content_type); + "proxy: FTP: Content-Type set to %s", + r->content_type ? r->content_type : "nothing"); #if defined(USE_MDTM) && (defined(HAVE_TIMEGM) || defined(HAVE_GMTOFF)) if (mtime != 0L) { char datestr[APR_RFC822_DATE_LEN]; apr_rfc822_date(datestr, mtime); apr_table_set(r->headers_out, "Last-Modified", datestr); ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server, diff -u7 -r orig-httpd-2.0.43/server/config.c httpd-2.0.43/server/config.c --- orig-httpd-2.0.43/server/config.c Thu Sep 12 15:04:07 2002 +++ httpd-2.0.43/server/config.c Sat Oct 26 16:49:33 2002 @@ -378,15 +378,15 @@ result = ap_invoke_filter_init(r->output_filters); if (result != OK) { return result; } if (!r->handler) { handler = r->content_type ? r->content_type : ap_default_type(r); - if ((p=ap_strchr_c(handler, ';')) != NULL) { + if (handler && (p=ap_strchr_c(handler, ';')) != NULL) { char *new_handler = (char *)apr_pmemdup(r->pool, handler, p - handler + 1); char *p2 = new_handler + (p - handler); handler = new_handler; /* MIME type arguments */ while (p2 > handler && p2[-1] == ' ') @@ -394,15 +394,17 @@ *p2='\0'; } r->handler = handler; } - result = ap_run_handler(r); + if (r->handler) { + result = ap_run_handler(r); + } r->handler = old_handler; if (result == DECLINED && r->handler && r->filename) { ap_log_rerror(APLOG_MARK, APLOG_WARNING, 0, r, "handler \"%s\" not found for: %s", r->handler, r->filename); } diff -u7 -r orig-httpd-2.0.43/server/core.c httpd-2.0.43/server/core.c --- orig-httpd-2.0.43/server/core.c Wed Oct 2 16:35:57 2002 +++ httpd-2.0.43/server/core.c Sat Oct 26 16:35:32 2002 @@ -657,15 +657,15 @@ core_dir_config *conf; conf = (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module); return conf->ap_default_type ? conf->ap_default_type - : DEFAULT_CONTENT_TYPE; + : NULL; } AP_DECLARE(const char *) ap_document_root(request_rec *r) /* Don't use this! */ { core_server_config *conf; conf = (core_server_config *)ap_get_module_config(r->server->module_config, diff -u7 -r orig-httpd-2.0.43/server/protocol.c httpd-2.0.43/server/protocol.c --- orig-httpd-2.0.43/server/protocol.c Wed Oct 2 08:41:45 2002 +++ httpd-2.0.43/server/protocol.c Sat Oct 26 16:52:12 2002 @@ -133,28 +133,33 @@ charset_pattern = apr_strmatch_precompile(pool, "charset=", 0); } /* * Builds the content-type that should be sent to the client from the * content-type specified. The following rules are followed: * - if type is NULL, type is set to ap_default_type(r) + * - if type is still NULL, return NULL * - if charset adding is disabled, stop processing and return type. * - then, if there are no parameters on type, add the default charset * - return type */ AP_DECLARE(const char *)ap_make_content_type(request_rec *r, const char *type) { const apr_strmatch_pattern **pcset; core_dir_config *conf = (core_dir_config *)ap_get_module_config(r->per_dir_config, &core_module); apr_size_t type_len; if (!type) { type = ap_default_type(r); + } + + if (!type) { + return NULL; } if (conf->add_default_charset != ADD_DEFAULT_CHARSET_ON) { return type; } type_len = strlen(type);