tag:blogger.com,1999:blog-36457300.post2057326621331575196..comments2023-07-28T04:53:06.555-07:00Comments on PeerIt.com: MultipartPostHandler doesn't work for unicode filesBrianhttp://www.blogger.com/profile/00802126410957566407noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-36457300.post-24223380537635956852013-07-23T03:14:42.720-07:002013-07-23T03:14:42.720-07:00thx a lot.thx a lot.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-36457300.post-85865593409641123282012-05-08T14:32:32.868-07:002012-05-08T14:32:32.868-07:00Very helpful, thank you!Very helpful, thank you!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-36457300.post-85232273113854091292008-10-06T01:49:00.000-07:002008-10-06T01:49:00.000-07:00how do I handle the upload on the server?thanks,how do I handle the upload on the server?<BR/><BR/>thanks,kcrishttps://www.blogger.com/profile/13676475052115378271noreply@blogger.comtag:blogger.com,1999:blog-36457300.post-46126220332757037032008-08-05T23:10:00.000-07:002008-08-05T23:10:00.000-07:00hey guys, I'm running into a problem myself but I ...hey guys, I'm running into a problem myself but I am unsure if this is a MultipartPostHandler error or not.<BR/><BR/>I am passing a form, it seems to encode just fine with MPhandler but I still seem to get an error stating I am missing form data. all form fields are filled out, my login/cookies seem to be fine, and from what I can see the headers are all set ok except for "Connection" it is set to "Connection: close" yet I am passing this value manually with request.add_header('Connection', 'Keep-Alive").<BR/><BR/>I have no idea where the error is, I am using fiddler2 to examine the form/header/cookie data and when comparing there is barely any difference from what I am using in my code and what FireFox3 sends.<BR/><BR/>My other q is why am I finding my local ip address mixed into the Content-Disposition line?? eg:<BR/><BR/>**START**<BR/>--192.168.1.101.1.13524.1217999622.504.1<BR/>Content-Disposition: form-data; name="url"<BR/><BR/>blah<BR/>**END**<BR/><BR/>192.168.1.101 is/was my local address assigned to my pc from my router. is this information needed? from what I see from FireFox3's sent request it is not and if I don't have to include this detail in my form I would prefer not too. :P<BR/><BR/>Any help with these two problems would be greatly appreciated :D<BR/><BR/>TIA!!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-36457300.post-57564055788511362472008-07-03T03:43:00.000-07:002008-07-03T03:43:00.000-07:00thanks for the lib, but I have a question for my c...thanks for the lib, but I have a question for my case. I cannot find the solution, can you help me out? thanx.<BR/><BR/>Even for logout action, I have to supply the 'data' var as following<BR/><B>[code works]<BR/>import MultipartPostHandler, cookielib<BR/>cookies = cookielib.CookieJar()<BR/>opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies),<BR/> MultipartPostHandler.MultipartPostHandler)<BR/>urllib2.install_opener(opener) <BR/>#in fact, they are read from the logged-in page <BR/>utmpnum, utmpkey, utmpuserid='12345678', '2345678', 'myid'<BR/>data = urllib.urlencode({<BR/> 'utmpnum':utmpnum,<BR/> 'utmpkey':utmpkey,<BR/> 'utmpuserid':utmpuserid})<BR/>myrequest = urllib2.Request('http://host/cgi-bin/bbslogout', data)<BR/>[/code works]</B><BR/>If I do not supply 'data', I was told "you are not logged in"<BR/> <BR/>for my case, I finished this code, but the response still says "you are not logged in"!<BR/><B>[code does not work]<BR/>import MultipartPostHandler, cookielib<BR/>cookies = cookielib.CookieJar()<BR/>opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookies),<BR/> MultipartPostHandler.MultipartPostHandler)<BR/>urllib2.install_opener(opener) <BR/>bbs_att_url='http://host/cgi-bin/bbsdoupload'<BR/><BR/>data = { <BR/> 'utmpnum':utmpnum,<BR/> 'utmpkey':utmpkey,<BR/> 'utmpuserid':utmpuserid,<BR/> 'up' : open("myfile.ico", "rb") ,<BR/> }<BR/>data=urllib.urlencode(data)<BR/>request = urllib2.Request(bbs_att_url, data) <BR/>fd=urllib2.urlopen(request)<BR/>data=fd.read()<BR/>print data<BR/>[/code does not work]</B>Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-36457300.post-52288886824703844692008-02-25T10:14:00.000-08:002008-02-25T10:14:00.000-08:00Thak you! Works for me.Thak you! Works for me.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-36457300.post-16854813143867799902007-11-15T16:05:00.000-08:002007-11-15T16:05:00.000-08:00OH MY GOD!! YES!!Thank-you! I've been trying to mo...OH MY GOD!! YES!!<BR/><BR/>Thank-you! I've been trying to modify the <B>very same code</B> from the link in your article to accept files with unicode characters, for the last two hours!<BR/><BR/>I was getting so frustrated, must have searched around 50 mailing lists. Then finally found this site halfway down google for "python urllib2 support for unicode". <BR/><BR/>It works perfectly. Thanks! This blog is now the first site I've ever bookmarked. Haha.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-36457300.post-56359134740509910262007-11-07T16:18:00.000-08:002007-11-07T16:18:00.000-08:00Thanks, it works like a charm! :)Thanks, it works like a charm! :)Anonymousnoreply@blogger.com