Esempio n. 1
0
    def test_8bitReceiving(self):
        d = defer.Deferred()
        rvr = client.ResponseReceiver(d, decode_utf8=False)

        data = util.eight_bit_test_string()
        d.addCallback(lambda out: self.assertEqual(out, data))

        for c in data:
            rvr.dataReceived(c)

        rvr.connectionLost(Failure(ResponseDone()))
Esempio n. 2
0
    def test_utf8Receiving(self):
        d = defer.Deferred()
        rvr = client.ResponseReceiver(d, decode_utf8=True)

        # "Internationalization" string from
        # http://rentzsch.tumblr.com
        # /post/9133498042/howto-use-utf-8-throughout-your-web-stack
        data = u'\u201cI\xf1t\xebrn\xe2ti\xf4n\xe0liz\xe6ti\xf8n\u201d'
        d.addCallback(lambda encoded_out: self.assertEqual(encoded_out, data))

        for c in data.encode('utf-8'):
            rvr.dataReceived(c)

        rvr.connectionLost(Failure(ResponseDone()))
Esempio n. 3
0
 def deliverBody(self, protocol):
     protocol.dataReceived(self.body)
     protocol.connectionLost(Failure(ResponseDone()))
Esempio n. 4
0
 def deliverBody(self, receiver):
     receiver.makeConnection(self)
     if self.producing and self.body:
         receiver.dataReceived(self.body)
     receiver.connectionLost(Failure(ResponseDone()))