[cse491] homework5
C. Titus Brown
ctb at msu.edu
Tue Sep 30 19:02:02 PDT 2008
On Tue, Sep 30, 2008 at 03:42:06PM -0400, Dillon Walls wrote:
-> Hey,Is there any easy way to parse the headers into a list of tuples? I've
-> used the buffer.split('\r\n\r\n', 1) and isolated them from the rest of the
-> data. But we still need to put them into list pairs. Second, how exactly is
-> delegate() supposed to change those headers? Or do we just throw them out
-> and return our made-up headers like in hw3/4 (Content-Type: text/html,
-> etc...) only in list form this time?
Hey Dillon,
well, I don't know what your definition of 'easy' is... :) Why not just
do
k, v = header_line.split(': ')
and then append (k, v) to the list of headers?
Yes, you should "throw out" the headers that come in, and return
completely distinct ones in list form.
-> And just to make sure, the sock.sendall() commands should be called outside
-> of delegate(), right? Like in handle_connections after delegate has returned
-> the right values or in some other helper function?
Right. 'delegate' doesn't know anything about the socket.
cheers,
--t
--
C. Titus Brown, ctb at msu.edu
More information about the cse491-fall-2008
mailing list