コード例 #1
0
ファイル: test_web_webserver.py プロジェクト: f3at/feat
class DummyPrivateRequest(object):

    def __init__(self, uri="/"):
        self.code = None
        self.method = "GET"
        self.clientproto = "HTTP/1.0"
        self.path = uri
        self.uri = uri
        self.client = address.IPv4Address("TCP", "127.0.0.1", 12345)
        self.host = address.IPv4Address("TCP", "127.0.0.2", 12345)
        self.content = StringIO()
        self.request_headers = {}
        self.responseHeaders = Headers()
        self._finished = defer.Deferred()
        self.channel = DummyPrivateChannel()

    def setResponseCode(self, code):
        self.code = code

    def finish(self):
        self._finished.callback(self)

    def getHeader(self, name):
        return self.request_headers.get(name.lower(), None)

    def setHeader(self, name, value):
        self.responseHeaders.setRawHeaders(name, [value])

    @property
    def response_headers(self):
        return dict((k.lower(), v[0])
                    for k, v in self.responseHeaders.getAllRawHeaders())

    @response_headers.setter
    def flush_response_headers(self, value):
        assert value == dict(), repr(value)
        self.responseHeaders = Headers()

    def write(self, data):
        self.content.write(data)

    def notifyFinish(self):
        d = defer.Deferred()
        self._finished.addCallback(defer.drop_param, d.callback, self)
        return d
コード例 #2
0
ファイル: test_web_webserver.py プロジェクト: f3at/feat
 def __init__(self, uri="/"):
     self.code = None
     self.method = "GET"
     self.clientproto = "HTTP/1.0"
     self.path = uri
     self.uri = uri
     self.client = address.IPv4Address("TCP", "127.0.0.1", 12345)
     self.host = address.IPv4Address("TCP", "127.0.0.2", 12345)
     self.content = StringIO()
     self.request_headers = {}
     self.responseHeaders = Headers()
     self._finished = defer.Deferred()
     self.channel = DummyPrivateChannel()
コード例 #3
0
def request_with_session(sid, method="GET"):
    r = Request(DummyChannel(), False)
    r.method = method
    r.requestHeaders = Headers({'Bloc-Session-ID': [sid]})
    return r
コード例 #4
0
ファイル: test_web_webserver.py プロジェクト: f3at/feat
 def flush_response_headers(self, value):
     assert value == dict(), repr(value)
     self.responseHeaders = Headers()