~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: John Arbash Meinel
  • Date: 2011-02-10 02:33:15 UTC
  • mto: This revision was merged to the branch mainline in revision 441.
  • Revision ID: john@arbash-meinel.com-20110210023315-515pkynlfpfs3cvm
Fix bug #716201 by suppressing body content when getting a HEAD request.

This adds some WSGI middleware that suppresses returning body content if a HEAD request
is received.

Note that we don't yet pass GET down to the lower levels, so they could still
decide whether they can do less work or not. We may want to make the standard BranchWSGIApp
do less work under those circumstances.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009, 2010 Canonical Ltd
 
1
# Copyright 2009, 2010, 2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
82
82
            sys.path.append(os.path.dirname(__file__))
83
83
 
84
84
    def serve_http(transport, host=None, port=None, inet=None):
 
85
        # TODO: if we supported inet to pass requests in and respond to them,
 
86
        #       then it would be easier to test the full stack, but it probably
 
87
        #       means routing around paste.httpserver.serve which probably
 
88
        #       isn't testing the full stack
85
89
        from paste.httpexceptions import HTTPExceptionHandler
86
90
        from paste.httpserver import serve
87
91
 
88
92
        _ensure_loggerhead_path()
89
93
 
 
94
        from loggerhead.apps.http_head import HeadMiddleware
90
95
        from loggerhead.apps.transport import BranchesFromTransportRoot
91
96
        from loggerhead.config import LoggerheadConfig
92
97
 
100
105
        config = LoggerheadConfig(argv)
101
106
        setup_logging(config)
102
107
        app = BranchesFromTransportRoot(transport.base, config)
 
108
        app = HeadMiddleware(app)
103
109
        app = HTTPExceptionHandler(app)
104
110
        serve(app, host=host, port=port)
105
111