You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Dean Gaudet <dg...@arctic.org> on 1997/05/04 23:19:00 UTC

[PATCH] PR#506: no DefaultType means no Content-Type

If there is no DefaultType then apache emits no Content-Type header. 

Our srm.conf-dist lists DefaultType text/plain, but httpd.h defines
DEFAULT_TYPE "text/html".  I changed httpd.h since usually the definitions
in httpd.h agree with the -dist conf files. 

mod_actions.c contained a test which always evaluates true --
default_type(r) is always non-NULL. 

Dean

Index: http_protocol.c
===================================================================
RCS file: /export/home/cvs/apache/src/http_protocol.c,v
retrieving revision 1.118
diff -c -3 -r1.118 http_protocol.c
*** http_protocol.c	1997/04/30 23:01:57	1.118
--- http_protocol.c	1997/05/04 21:14:35
***************
*** 1172,1180 ****
  {
      int i;
      const long int zero = 0L;
-     core_dir_config *dir_conf =
-       (core_dir_config *)get_module_config(r->per_dir_config, &core_module);
-     char *default_type = dir_conf->default_type;
    
      if (r->assbackwards) {
          if(!r->main)
--- 1172,1177 ----
***************
*** 1206,1213 ****
                            "byteranges; boundary=", r->boundary, NULL));
      else if (r->content_type)
          table_set(r->headers_out, "Content-Type", r->content_type);
!     else if (default_type)
!         table_set(r->headers_out, "Content-Type", default_type);
      
      if (r->content_encoding)
          table_set(r->headers_out, "Content-Encoding", r->content_encoding);
--- 1203,1210 ----
                            "byteranges; boundary=", r->boundary, NULL));
      else if (r->content_type)
          table_set(r->headers_out, "Content-Type", r->content_type);
!     else 
!         table_set(r->headers_out, "Content-Type", default_type(r));
      
      if (r->content_encoding)
          table_set(r->headers_out, "Content-Encoding", r->content_encoding);
Index: httpd.h
===================================================================
RCS file: /export/home/cvs/apache/src/httpd.h,v
retrieving revision 1.102
diff -c -3 -r1.102 httpd.h
*** httpd.h	1997/04/29 05:18:53	1.102
--- httpd.h	1997/05/04 21:14:35
***************
*** 135,141 ****
  
  /* Define this to be what type you'd like returned for files with unknown */
  /* suffixes */
! #define DEFAULT_TYPE "text/html"
  
  /* Define this to be what your per-directory security files are called */
  #ifdef __EMX__
--- 135,141 ----
  
  /* Define this to be what type you'd like returned for files with unknown */
  /* suffixes */
! #define DEFAULT_TYPE "text/plain"
  
  /* Define this to be what your per-directory security files are called */
  #ifdef __EMX__
Index: mod_actions.c
===================================================================
RCS file: /export/home/cvs/apache/src/mod_actions.c,v
retrieving revision 1.11
diff -c -3 -r1.11 mod_actions.c
*** mod_actions.c	1997/03/07 14:15:37	1.11
--- mod_actions.c	1997/05/04 21:14:35
***************
*** 177,183 ****
          return DECLINED;
  
      /* Second, check for actions (which override the method scripts) */
!     if ((action || default_type(r)) && (t = table_get(conf->action_types,
  					action ? action : default_type(r)))) {
          script = t;
  	if (r->finfo.st_mode == 0) {
--- 177,183 ----
          return DECLINED;
  
      /* Second, check for actions (which override the method scripts) */
!     if ((t = table_get(conf->action_types,
  					action ? action : default_type(r)))) {
          script = t;
  	if (r->finfo.st_mode == 0) {



Re: [PATCH] PR#506: no DefaultType means no Content-Type

Posted by Dean Gaudet <dg...@arctic.org>.
Ya know, after looking at all the code that references content_type there
is some that should do

    r->content_type ? r->content_type : default_type(r);

In fact it seems to me that we should just set
r->content_type = default_type(r) way early on in the request processing.

Look at mod_include and mod_dir for example, they're broken on files that
get their Content-Type set by DefaultType.

The best place might be in http_core, add a type_checker function like
this:

static int core_type_checker (request_rec *r)
{
    if (!r->content_type) {
	r->content_type = default_type (r);
    }
    return OK;
}

Dean

On Sun, 4 May 1997, Dean Gaudet wrote:

> If there is no DefaultType then apache emits no Content-Type header. 
> 
> Our srm.conf-dist lists DefaultType text/plain, but httpd.h defines
> DEFAULT_TYPE "text/html".  I changed httpd.h since usually the definitions
> in httpd.h agree with the -dist conf files. 
> 
> mod_actions.c contained a test which always evaluates true --
> default_type(r) is always non-NULL.