Author martin.panter
Recipients barry, flox, janssen, martin.panter, mgiuca, orsenthil, r.david.murray
Date 2015-02-19.02:39:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1424313572.38.0.0206356784897.issue3609@psf.upfronthosting.co.za>
In-reply-to
Content
HTTP policy sounds as good a place as any, especially if/when it is blessed as a stable API.

Another related function is the undocumented http.cookiejar.split_header_words(), which seems more flexible than cgi.parse_headers(). It accepts multiple and comma-separated header values, splits on spaces as well as semicolons, and retains parameters without equal signs. Currently I have code that abuses the Message.get_params() and get_param() methods, which could probably benefit from split_header_words():

# Parse RTSP Transport headers like
# Transport: RTP/AVP/TCP;interleaved=0-1, RTP/AVP;unicast;client_port=5004
for value in header_list(self.headers, "Transport"):  # Splits at commas
    header = email.message.Message()
    # Default get_params() header is Content-Type
    header["Content-Type"] = value
    [transport, _] = header.get_params()[0]  # Gets the RTP/AVP part
    
    mode = header.get_param("mode", "PLAY")
    channel = header.get_param("interleaved")
    if header.get_param("unicast") is not None:
        port = header.get_param("client_port")
    ...
History
Date User Action Args
2015-02-19 02:39:32martin.pantersetrecipients: + martin.panter, barry, janssen, orsenthil, mgiuca, r.david.murray, flox
2015-02-19 02:39:32martin.pantersetmessageid: <1424313572.38.0.0206356784897.issue3609@psf.upfronthosting.co.za>
2015-02-19 02:39:32martin.panterlinkissue3609 messages
2015-02-19 02:39:31martin.pantercreate