changeset 4:4e6ce85226f4

Fixed a bug in receiving of data.
author Atul Varma <varmaa@toolness.com>
date Fri, 17 Apr 2009 16:23:31 -0700
parents 9e819377ce9f
children 4ec829dc7d1d
files taw.py
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/taw.py	Fri Apr 17 16:17:37 2009 -0700
+++ b/taw.py	Fri Apr 17 16:23:31 2009 -0700
@@ -47,6 +47,7 @@
     def found_terminator(self):
         self.set_terminator(None)
         data = ''.join(self.__data)
+        self.__data = []
         self.__process_next_instruction(data)
 
 class ChattyCoroutineServer(asyncore.dispatcher):
@@ -94,8 +95,11 @@
 
 def lame_http_client_coroutine(chat, addr):
     yield chat.send('GET / HTTP/1.1\r\n\r\n')
-    response = yield chat.receive(terminator = '\r\n\r\n')
-    print response
+    response_headers = yield chat.receive(terminator = '\r\n\r\n')
+    response = yield chat.receive(20)
+    print 'first response: %s' % repr(response)
+    response = yield chat.receive(20)
+    print 'second response: %s' % repr(response)
 
 if __name__ == '__main__':
     server = ChattyCoroutineServer(('127.0.0.1', 8071),