Branch: Tag:

2010-05-25

2010-05-25 09:04:54 by Martin Jonsson <marty@roxen.com>

Break out Content-Type header fallback code to get_response_content_type() to
be able to get the request's final content type before actually constructing
the headers.

Rev: server/base_server/prototypes.pike:1.270

5:   #include <config.h>   #include <module.h>   #include <module_constants.h> - constant cvs_version="$Id: prototypes.pike,v 1.269 2010/05/19 06:56:41 noring Exp $"; + constant cvs_version="$Id: prototypes.pike,v 1.270 2010/05/25 09:04:54 marty Exp $";      #ifdef DAV_DEBUG   #define DAV_WERROR(X...) werror(X)
2971:    return f;    }    +  string get_response_content_type (mapping file, +  void|int(1..1) destructive) +  { +  string|array(string) type = file->type; +  if (mappingp (file->extra_heads) && file->extra_heads["Content-Type"]) { +  type = file->extra_heads["Content-Type"]; +  if (destructive) m_delete (file->extra_heads, "Content-Type"); +  } +  if (mappingp (misc->moreheads) && misc->moreheads["Content-Type"]) { +  type = misc->moreheads["Content-Type"]; +  if (destructive) m_delete (misc->moreheads, "Content-Type"); +  } +  if (arrayp (type)) type = type[0]; +  +  return type || "text/plain"; +  } +     mapping(string:string|array(string)) make_response_headers (    mapping(string:mixed) file)    //! Make the response headers from a response mapping for this
3003:    if (!file->error)    file->error = Protocols.HTTP.HTTP_OK;    -  if(!file->type) file->type="text/plain"; +  string type = get_response_content_type (file, 1);    -  string|array(string) type = file->type; -  if (mappingp (file->extra_heads) && file->extra_heads["Content-Type"]) -  type = m_delete (file->extra_heads, "Content-Type"); -  if (mappingp (misc->moreheads) && misc->moreheads["Content-Type"]) -  type = m_delete (misc->moreheads, "Content-Type"); -  if (arrayp (type)) type = type[0]; -  +     mapping(string:string) heads = ([]);       // Collect info about language forks and their protocol cache callbacks