You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by st...@covalent.net on 2002/03/08 02:43:20 UTC

[PATCH] Re: Apache 2.0.34-dev Sends Wrong Content-Type on 404

On Thu, 7 Mar 2002, Jerry Baker wrote:

> Apache 2.0.34-dev pulled from CVS today is sending text/plain as the
> content-type on 404 responses. See example below:
> 
> HTTP/1.1 404 Not Found
> Date: Thu, 07 Mar 2002 21:23:10 GMT
> Server: Apache/2.0.34-dev (Win32)
> Vary: accept-language
> Content-Length: 794
> Connection: close
> Content-Type: text/plain; charset=ISO-8859-1
> 
> This, or course, makes the 404 response appear as a screen full of HTML
> code instead of how it should.


I think this is a general problem with get_canned_error_string - something 
like the following should fix that


Index: modules/http/http_protocol.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/http/http_protocol.c,v
retrieving revision 1.393
diff -u -r1.393 http_protocol.c
--- modules/http/http_protocol.c	4 Mar 2002 05:54:44 -0000	1.393
+++ modules/http/http_protocol.c	8 Mar 2002 01:42:06 -0000
@@ -1618,6 +1618,7 @@
     apr_pool_t *p = r->pool;
     const char *error_notes, *h1, *s1;
 
+    r->content_type = "text/html";
     switch (status) {
     case HTTP_MOVED_PERMANENTLY:
     case HTTP_MOVED_TEMPORARILY:


Re: [PATCH] Re: Apache 2.0.34-dev Sends Wrong Content-Type on 404

Posted by st...@covalent.net.
On Thu, 7 Mar 2002, Justin Erenkrantz wrote:

> On Thu, Mar 07, 2002 at 08:57:42PM -0800, sterling@covalent.net wrote:
> > well, the workaround is to set DefaultType text/html.  The real problem, 
> > however, seems to be the fact that only the subrequest gets the content 
> > type set to text/html in this case, while the main request still has the 
> > content_type set to NULL (hence it uses the default).
> > 
> > I'll work on a patch that properly sets the content type to the type in 
> > the var file.
> 
> Shouldn't the subreq's content-type be propogated upwards when we
> do the fast_redirect?  -- justin


I would think so, but on first look the r->content_type=text/html but the 
request that gets passed through the filter at the end 
r->content_type=NULL.

I'll keep looking at it later.  I did notice that if I manually set 
r->prev->content_type=mime_info.mime_type then everything 'just works' 
(but is a hack like the following):

Index: modules/mappers/mod_negotiation.c
===================================================================
RCS file: /home/cvspublic/httpd-2.0/modules/mappers/mod_negotiation.c,v
retrieving revision 1.95
diff -u -r1.95 mod_negotiation.c
--- modules/mappers/mod_negotiation.c	13 Feb 2002 02:55:17 -0000	1.95
+++ modules/mappers/mod_negotiation.c	8 Mar 2002 18:13:34 -0000
@@ -939,6 +939,8 @@
 
                 get_entry(neg->pool, &accept_info, body);
                 set_mime_fields(&mime_info, &accept_info);
+                if( r->prev )
+                    r->prev->content_type = mime_info.mime_type;
                 has_content = 1;
             }
             else if (!strncmp(buffer, "content-length:", 15)) {


Re: [PATCH] Re: Apache 2.0.34-dev Sends Wrong Content-Type on 404

Posted by Justin Erenkrantz <je...@ebuilt.com>.
On Thu, Mar 07, 2002 at 08:57:42PM -0800, sterling@covalent.net wrote:
> well, the workaround is to set DefaultType text/html.  The real problem, 
> however, seems to be the fact that only the subrequest gets the content 
> type set to text/html in this case, while the main request still has the 
> content_type set to NULL (hence it uses the default).
> 
> I'll work on a patch that properly sets the content type to the type in 
> the var file.

Shouldn't the subreq's content-type be propogated upwards when we
do the fast_redirect?  -- justin


Re: [PATCH] Re: Apache 2.0.34-dev Sends Wrong Content-Type on 404

Posted by st...@covalent.net.
On Thu, 7 Mar 2002, Jerry Baker wrote:

> sterling@covalent.net wrote:
> > 
> > On Thu, 7 Mar 2002, Jerry Baker wrote:
> > 
> > > Do you think that Apache is not reading the HTTP_NOT_FOUND.html.var file
> > > correctly which explicitly states that it should be text/html?
> > 
> > is it showing the content from that var file?  what is the content you are
> > seeing (the plain html).
> > 
> > sterling
> 
> Straight out of the var file (from the "en" section).


well, the workaround is to set DefaultType text/html.  The real problem, 
however, seems to be the fact that only the subrequest gets the content 
type set to text/html in this case, while the main request still has the 
content_type set to NULL (hence it uses the default).

I'll work on a patch that properly sets the content type to the type in 
the var file.

sterling


Re: [PATCH] Re: Apache 2.0.34-dev Sends Wrong Content-Type on 404

Posted by Jerry Baker <je...@weirdness.com>.
sterling@covalent.net wrote:
> 
> On Thu, 7 Mar 2002, Jerry Baker wrote:
> 
> > Do you think that Apache is not reading the HTTP_NOT_FOUND.html.var file
> > correctly which explicitly states that it should be text/html?
> 
> is it showing the content from that var file?  what is the content you are
> seeing (the plain html).
> 
> sterling

Straight out of the var file (from the "en" section).

-- 
Jerry Baker

Re: [PATCH] Re: Apache 2.0.34-dev Sends Wrong Content-Type on 404

Posted by Jerry Baker <je...@weirdness.com>.
sterling@covalent.net wrote:
> 
> On Thu, 7 Mar 2002, Jerry Baker wrote:
> 
> > Do you think that Apache is not reading the HTTP_NOT_FOUND.html.var file
> > correctly which explicitly states that it should be text/html?
> 
> is it showing the content from that var file?  what is the content you are
> seeing (the plain html).
> 
> sterling

HTML
-------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Object not found!</TITLE>
<LINK REV="made" HREF="mailto:jerrybaker@weirdness.com">
</HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000CC">
<H1>Object not found!</H1>
<DL>
<DD>


    The requested URL was not found on this server.

  

    If you entered the URL manually please check your
    spelling and try again.

  

</DL><DL><DD>
 If you think this is a server error, please contact
 the <A HREF="mailto:jerrybaker@weirdness.com">webmaster</A>

</DL>

<H2>Error 404</H2>
<DL>
<DD>
<ADDRESS>
  <A HREF="/">jerbaker.dhs.org</A>
  <BR>
  
  <small>03/07/02 21:01:42</small>
  <BR>
  <small>Apache/2.0.34-dev (Win32)</small>
</ADDRESS>
</DL>
</BODY>
</HTML>
--------------

-- 
Jerry Baker

Re: [PATCH] Re: Apache 2.0.34-dev Sends Wrong Content-Type on 404

Posted by st...@covalent.net.
On Thu, 7 Mar 2002, Jerry Baker wrote:

> Do you think that Apache is not reading the HTTP_NOT_FOUND.html.var file
> correctly which explicitly states that it should be text/html?

is it showing the content from that var file?  what is the content you are 
seeing (the plain html).

sterling


Re: [PATCH] Re: Apache 2.0.34-dev Sends Wrong Content-Type on 404

Posted by Jerry Baker <je...@attbi.com>.
sterling@covalent.net wrote:
> 
> I think this is a general problem with get_canned_error_string - something
> like the following should fix that

Do you think that Apache is not reading the HTTP_NOT_FOUND.html.var file
correctly which explicitly states that it should be text/html?

-- 
Jerry Baker

Re: [PATCH] Re: Apache 2.0.34-dev Sends Wrong Content-Type on 404

Posted by Jerry Baker <je...@weirdness.com>.
sterling@covalent.net wrote:
> 
> I think this is a general problem with get_canned_error_string - something
> like the following should fix that

This patch does not appear to remedy the problem here on Win32.

-- 
Jerry Baker

Re: [PATCH] Re: Apache 2.0.34-dev Sends Wrong Content-Type on 404

Posted by Aaron Bannert <aa...@clove.org>.
On Thu, Mar 07, 2002 at 05:43:20PM -0800, John Sterling wrote:
> I think this is a general problem with get_canned_error_string - something 
> like the following should fix that
> 
> 
> Index: modules/http/http_protocol.c
> ===================================================================
> RCS file: /home/cvspublic/httpd-2.0/modules/http/http_protocol.c,v
> retrieving revision 1.393
> diff -u -r1.393 http_protocol.c
> --- modules/http/http_protocol.c	4 Mar 2002 05:54:44 -0000	1.393
> +++ modules/http/http_protocol.c	8 Mar 2002 01:42:06 -0000
> @@ -1618,6 +1618,7 @@
>      apr_pool_t *p = r->pool;
>      const char *error_notes, *h1, *s1;
>  
> +    r->content_type = "text/html";
>      switch (status) {
>      case HTTP_MOVED_PERMANENTLY:
>      case HTTP_MOVED_TEMPORARILY:

John posted this patch awhile ago. I'm +1 and will commit in 24 hours
unless someone speaks up with a reason not to.

-aaron