Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > urllib2/httplib and email mime

Thread Tools

urllib2/httplib and email mime

Posts: n/a
Hello All,

I am using email to create a multipart message that I need to post to
a url.

I have been doing it semi-manually with httplib:

h = httplib.HTTP(
h.putrequest("POST", self.url)
# Lot of other headers here...
# Here is where it gets ugly
h.putheader("Content-Type", 'multipart/mixed;
# Where I had to figure out what that was from my Message object I
created earlier.

# Now do ugly stuff to strip off the first 2 lines from my
# (omited due to modesty... It's too ugly)
h.putheader("Content-length", str(len(stripped_msg)))

Can someone sugest a cleaner way of doing this sort of thing using
urllib2? The problem is getting the Content-Type header from my email
object to be used by urllib2 as an http header.


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
which email module - MIME::LITE, Email::Send, other? Perl Misc 2 01-05-2007 09:45 AM
Problem with Email::MIME and Email::MIME::Attachment::Stripper ecureuil Perl Misc 0 05-28-2006 01:47 AM
tomcat 4.x : setting mime type for a directory or setting a default mime type CJ Java 1 10-29-2004 07:51 PM
how 2 convert mime to txt or extract words from mime joe Perl Misc 0 04-07-2004 12:34 AM
Receiving zip files via Mime::Parser/Mime::Decoder Jan Arickx Perl Misc 0 08-25-2003 08:24 PM