X-Git-Url: http://www.dolda2000.com/gitweb/?p=ashd.git;a=blobdiff_plain;f=python3%2Fashd%2Fproto.py;h=7a078de57feeb2d7957b4042836f976b146fea1c;hp=ab2152e0498fd76b4a67ddacf6a96fa29226d2ce;hb=f56b079086cb35e50697a4752b38679ae5e44679;hpb=173e0e9efec5ae690cc157fe238113fcd814895e diff --git a/python3/ashd/proto.py b/python3/ashd/proto.py index ab2152e..7a078de 100644 --- a/python3/ashd/proto.py +++ b/python3/ashd/proto.py @@ -32,10 +32,13 @@ class req(object): Python stream object in the `sk' variable. Again, see the ashd(7) manpage for what to receive and transmit on the response socket. - Note that instances of this class contain a reference to the live - socket used for responding to requests, which should be closed - when you are done with the request. The socket can be closed - manually by calling the close() method on this + Note that all request parts are stored in byte, rather than + string, form. The response socket is also opened in binary mode. + + Note also that instances of this class contain a reference to the + live socket used for responding to requests, which should be + closed when you are done with the request. The socket can be + closed manually by calling the close() method on this object. Alternatively, this class implements the resource-manager interface, so that it can be used in `with' statements. """ @@ -60,6 +63,9 @@ class req(object): req["Content-Type"] returns the value of the content-type header regardlessly of whether the client specified it as "Content-Type", "content-type" or "Content-type". + + If the header is given as a (Unicode) string, it is encoded + into Ascii for use in matching. """ if isinstance(header, str): header = header.encode("ascii") @@ -93,6 +99,9 @@ class req(object): string off and returns True. Otherwise, it returns False without doing anything. + If the `match' argument is given as a (Unicode) string, it is + encoded into UTF-8. + This can be used for simple dispatching. For example: if req.match("foo/"): handle(req) @@ -129,8 +138,8 @@ def recvreq(sock = 0): done, to avoid leaking response sockets. If end-of-file is received on the socket, None is returned. - This function may either raise on OSError if an error occurs on - the socket, or a ashd.proto.protoerr if the incoming request is + This function may either raise an OSError if an error occurs on + the socket, or an ashd.proto.protoerr if the incoming request is invalidly encoded. """ data, fd = htlib.recvfd(sock)