circuits.web.wrappers module¶
Request/Response Wrappers
This module implements the Request and Response objects.
-
class
circuits.web.wrappers.
Host
(ip, port, name=None)¶ Bases:
object
An internet address.
name should be the client’s host name. If not available (because no DNS lookup is performed), the IP address should be used instead.
-
ip
= '0.0.0.0'¶
-
name
= 'unknown.tld'¶
-
port
= 80¶
-
-
class
circuits.web.wrappers.
Request
(sock, method='GET', scheme='http', path='/', protocol=(1, 1), qs='', headers=None, server=None)¶ Bases:
object
Creates a new Request object to hold information about a request.
Parameters: - sock (socket.socket) – The socket object of the request.
- method (str) – The requested method.
- scheme (str) – The requested scheme.
- path (str) – The requested path.
- protocol (str) – The requested protocol.
- qs (str) – The query string of the request.
initializes x; see x.__class__.__doc__ for signature
-
handled
= False¶
-
host
= ''¶
-
index
= None¶
-
local
= Host('127.0.0.1', 80, '127.0.0.1')¶
-
login
= None¶
-
protocol
= (1, 1)¶
-
remote
= Host('', 0, '')¶
-
scheme
= 'http'¶
-
script_name
= ''¶
-
server
= None¶
-
class
circuits.web.wrappers.
Response
(sock, request) → new Response object¶ Bases:
object
A Response object that holds the response to send back to the client. This ensure that the correct data is sent in the correct order.
initializes x; see x.__class__.__doc__ for signature
-
body
¶ Response Body
-
chunked
= False¶
-
close
= False¶
-
done
= False¶
-
prepare
()¶
-
status
¶ Response Status
-
stream
= False¶
-
-
class
circuits.web.wrappers.
Status
¶ Bases:
object
Response Status
-
circuits.web.wrappers.
file_generator
(input, chunkSize=4096)¶
-
circuits.web.wrappers.
formatdate
(timeval=None, localtime=False)¶ Returns a date string as specified by RFC 2822, e.g.:
Fri, 09 Nov 2001 01:08:47 -0000
Optional timeval if given is a floating point time value as accepted by gmtime() and localtime(), otherwise the current time is used.
Optional localtime is a flag that when True, interprets timeval, and returns a date relative to the local timezone instead of UTC, properly taking daylight savings time into account.
Optional argument usegmt means that the timezone is written out as an ascii string, not numeric one (so “GMT” instead of “+0000”). This is needed for HTTP, and is only used when localtime==False.