weblib.http

weblib.http.encode_cookies(items, join=True, charset='utf-8')[source]

Serialize dict or sequence of two-element items into string suitable for sending in Cookie http header.

weblib.http.normalize_http_values(items, charset='utf-8', ignore_classes=None)[source]

Accept sequence of (key, value) paris or dict and convert each value into bytestring.

Unicode is converted into bytestring using charset of previous response (or utf-8, if no requests were performed)

None is converted into empty string.

If ignore_classes is not None and the value is instance of any classes from the ignore_classes then the value is not processed and returned as-is.

weblib.http.normalize_unicode(value, charset='utf-8')[source]

Convert unicode into byte-string using detected charset (default or from previous response)

By default, charset from previous response is used to encode unicode into byte-string but you can enforce charset with charset option

weblib.http.smart_urlencode(items, charset='utf-8')[source]

Convert sequence of items into bytestring which could be submitted in POST or GET request.

It differs from urllib.urlencode in that it can process unicode and some special values.

items could dict or tuple or list.