Package dap :: Package util :: Module wsgi_intercept :: Class wsgi_fake_socket
[hide private]
[frames] | no frames]

Class wsgi_fake_socket

source code

Handle HTTP traffic and stuff into a WSGI application object instead.

Note that this class assumes:
  1. 'makefile' is called (by the response class) only after all of the data has been sent to the socket by the request class;
  2. non-persistent (i.e. non-HTTP/1.1) connections.


Instance Methods [hide private]
  __init__(self, app, host, port, script_name)
  makefile(self, *args, **kwargs)
'makefile' is called by the HTTPResponse class once all of the data has been written.
  sendall(self, str)
Save all the traffic to self.inp.
  close(self)
Do nothing, for now.

Method Details [hide private]

__init__(self, app, host, port, script_name)
(Constructor)

source code 
None

makefile(self, *args, **kwargs)

source code 
'makefile' is called by the HTTPResponse class once all of the data has been written. So, in this interceptor class, we need to:
  1. build a start_response function that grabs all the headers returned by the WSGI app;
  2. create a wsgi.input file object 'inp', containing all of the traffic;
  3. build an environment dict out of the traffic in inp;
  4. run the WSGI app & grab the result object;
  5. concatenate & return the result(s) read from the result object.

sendall(self, str)

source code 
Save all the traffic to self.inp.

close(self)

source code 
Do nothing, for now.