httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From (Rodent of Unusual Size)
Subject Re: Server-generated content-type?
Date Sun, 30 Mar 1997 04:29:39 GMT
>From the fingers of "Roy T. Fielding" flowed the following:
>Ken writes:
>>    Working on mod_example, the handler of which emits text/plain
>>    content, I found I was having trouble getting the Content-type
>>    header sent to the client correctly.  No matter what I did, Apache
>>    would rewrite this header to "text/html".  I finally stole a
>>    workaround from another module and now force *my* setting to be sent
>>    by calling send_http_header() at the beginning of the handler
>>    routine.
>Why don't you just set r->content_type?  The behavior is ancient, as far
>as I can tell, but it would be easy to add a check for an existing
>Content-Type before setting it to the default_type.

    In actual point of fact, there was some sort of flaw (or invalid
    assumption) in my original tests.  Apache *isn't* rewriting the
    Content-type header.  What is actually happening is that Apache
    isn't emitting *any* headers, and it's the *browser* that's
    interpreting the un-headered document as "text/html".  Nothing gets
    put into the output buffer automatically.

    I see two ways to deal with this: either ensure that any headers get
    dumped into the buffer first, triggered by the first data write, or
    else document the semantics of content handlers as requiring a call
    to send_http_header() before any data is emitted.  The former feels
    right but could be quite messy; the latter seems rather like a
    cop-out but would be extraordinarily simple. ;->

    The force-headers-first approach seems more correct partially
    because multiple people seem to have believed that's how it
    worked.  It does seem more intuitive that way, IMHO.

    If the feeling is that we're too close to release, I'll document
    this in the API stuff (and the example module).  If the consensus is
    that it  should work the way we thought it did, and that the current
    behaviour is a bug, I'll try to come up with a fix.  Either way,
    I'll generate a patch.


    #ken    :-)}

View raw message