def read_stream_body(stream, callback):
 chunks = []
 class Delegate(HTTPMessageDelegate, ):
  def headers_received(self, start_line, headers):
   self.headers = headers
  def data_received(self, chunk):
   chunks.append(chunk)
  def finish(self):
   callback((self.headers, ''.join(chunks)))
 conn = HTTP1Connection(stream, True)
 conn.read_response(Delegate())

def read_stream_body ( stream , callback ) : chunks = [ ] class Delegate ( HTTPMessageDelegate , ) : def headers_received ( self , start_line , headers ) : self . headers = headers def data_received ( self , chunk ) : chunks . append ( chunk ) def finish ( self ) : callback ( ( self . headers , '' . join ( chunks ) ) ) conn = HTTP1Connection ( stream , True ) conn . read_response ( Delegate ( ) )
reads an http response from stream and runs callback with its headers and body .