Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 859

Show
Ignore:
Timestamp:
12/05/05 15:14:59
Author:
lawouach
Message:

you can now define the default content type to be used globally by all responses using server.default._content_type

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/_cphttptools.py

    r858 r859  
    380380        self.headers = httptools.HeaderMap() 
    381381        self.headerMap = self.headers # Backward compatibility 
     382        content_type = cherrypy.config.get('server.default_content_type', 'text/html') 
    382383        self.headers.update({ 
    383             "Content-Type": "text/html"
     384            "Content-Type": content_type
    384385            "Server": "CherryPy/" + cherrypy.__version__, 
    385386            "Date": httptools.HTTPDate(), 
  • trunk/cherrypy/test/test_core.py

    r856 r859  
    904904        self.assertEqual(results, ["None"] * 20) 
    905905 
     906    def testDefaultContentType(self): 
     907        self.getPage('/') 
     908        self.assertHeader('Content-Type', 'text/html') 
     909         
     910        cherrypy.config.update({'server.default_content_type': 'text/plain'}) 
     911        self.getPage('/') 
     912        self.assertHeader('Content-Type', 'text/plain') 
    906913 
    907914if __name__ == '__main__': 
  • trunk/docs/book/xml/configreference.xml

    r857 r859  
    2626        <para><option>[global] server.max_request_header_size</option>: maximum acceptable size of a request header, in bytes (defaults to 500KB). If a longer request arrives, the server will interrupt it and return a 413 error. This setting is global (ie: doesn't depend on the path). Set it to zero to remove the limit</para> 
    2727      </listitem> 
     28            <listitem> 
     29                    <para><option>[global] server.default_content_type</option>: default content type to be used for all responses (default to text/html). This setting is global (ie: doesn't depend on the path).</para> 
     30            </listitem> 
    2831      <listitem> 
    2932        <para><option>[/path] server.max_request_body_size</option>: maximum acceptable size of a request body, in bytes (defaults to 100MB). If a longer request body arrives, the server will interrupt it and return a 413 error. This setting can be configured per path. This is useful to limit the size of uploaded files. Set it to zero to remove the limit</para> 

Hosted by WebFaction

Log in as guest/cpguest to create tickets