Beispiel #1
0
    def __init__(self, site, method, prepath, uri, length=None,
                 headers=None, version=(1, 1), content=None):
        self.producer = None
        self.site = site
        self.method = method
        self.prepath = prepath
        self.uri = uri
        if headers is None:
            headers = http_headers.Headers()
        self.headers = headers
        self.http_version = version
        # Anything below here we do not pass as arguments
        self.request = server.Request(self,
                                      self.method,
                                      self.uri,
                                      self.http_version,
                                      length,
                                      self.headers,
                                      site=self.site,
                                      prepathuri=self.prepath)

        if content is not None:
            self.request.handleContentChunk(content)
            self.request.handleContentComplete()

        self.code = None
        self.responseHeaders = None
        self.data = ''
        self.deferredFinish = defer.Deferred()
Beispiel #2
0
 def test_processingReallyReallyReallyFailed(self):
     """
     The HTTP connection will be shut down if there's really no way to relay
     any useful information about the error to the HTTP client.
     """
     root = ErrorWithProducerResource()
     site = server.Site(root)
     tcr = TestChanRequest(site, "GET", "/", "http://localhost/")
     request = server.Request(
         tcr, "GET", "/", (1, 1),
         0, http_headers.Headers({"host": "localhost"}),
         site=site)
     proc = request.process()
     done = []
     proc.addBoth(done.append)
     self.assertEquals(done, [None])
     errs = self.flushLoggedErrors(ValueError)
     self.assertIn('producer', str(errs[0]).lower())
     errs = self.flushLoggedErrors(MyRenderError)
     self.assertEquals(bool(errs), True)
     self.assertEquals(tcr.finished, True)