def _encode_multipart_formdata(fields, files):
BOUNDARY = '<STR_LIT>'<EOL>CRLF = '<STR_LIT:\r\n>'<EOL>L = []<EOL>for (key, value) in fields:<EOL><INDENT>L.append('<STR_LIT>' + BOUNDARY)<EOL>L.append(str('<STR_LIT>' % key))<EOL>L.append('<STR_LIT>')<EOL>L.append(value)<EOL><DEDENT>for (key, filename, value) in files:<EOL><INDENT>L.append('<STR_LIT>' + BOUNDARY)<EOL>L.append(str('<STR_LIT>' % (key, filename)))<EOL>L.append('<STR_LIT>' % get_content_type(filename))<EOL>L.append('<STR_LIT>')<EOL>L.append(value)<EOL><DEDENT>L.append('<STR_LIT>' + BOUNDARY + '<STR_LIT>')<EOL>L.append('<STR_LIT>')<EOL>body = CRLF.join(L)<EOL>content_type = '<STR_LIT>' % BOUNDARY<EOL>return content_type, body<EOL>
Create a multipart encoded form for use in PUTing and POSTing.

fields is a sequence of (name, value) elements for regular form fields.
files is a sequence of (name, filename, value) elements for data to be uploaded as files
Return (content_type, body) ready for httplib.HTTP instance