Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #5219
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <michiel@wedemandhtml.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'debug': 0.03; 'string,': 0.05; 'fine,': 0.07; 'python': 0.07; "'http/1.1": 0.09; '2.6:': 0.16; '201': 0.16; 'later:': 0.16; 'send:': 0.16; 'worked.': 0.16; 'subject:file': 0.16; 'compile': 0.19; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.20; 'code,': 0.20; 'seems': 0.21; 'maybe': 0.21; 'code': 0.22; 'header:In-Reply-To:1': 0.22; 'cc:addr:python- list': 0.22; 'incorrect': 0.23; 'moreover,': 0.23; 'worked': 0.24; 'checked': 0.25; 'received:209.85.161.46': 0.26; 'received:mail- fx0-f46.google.com': 0.26; 'xml': 0.26; 'url:mailman': 0.27; 'pass': 0.27; 'tried': 0.27; 'message-id:@mail.gmail.com': 0.28; 'received:209.85.161': 0.29; 'string': 0.29; 'mode': 0.29; 'class': 0.29; 'fine.': 0.29; 'cc:addr:python.org': 0.31; 'alongside': 0.31; 'complain': 0.31; 'does': 0.31; 'fact': 0.31; "can't": 0.31; 'another': 0.32; 'url:listinfo': 0.33; 'bit': 0.33; 'file.': 0.34; 'file': 0.35; 'that,': 0.35; 'put': 0.35; '2.6': 0.35; 'data': 0.37; 'way.': 0.37; 'received:209.85': 0.37; 'url:python': 0.37; 'subject:with': 0.37; '2.5': 0.38; 'received:google.com': 0.38; 'but': 0.38; 'happens': 0.38; 'url:org': 0.38; 'though': 0.38; 'docs': 0.39; 'earlier': 0.39; 'stable': 0.39; 'could': 0.39; 'received:209': 0.39; 'add': 0.39; 'header:Received:5': 0.40; 'demand': 0.60; 'soon': 0.76; '2.7.1': 0.84; 'expects': 0.84 |
| MIME-Version | 1.0 |
| X-Originating-IP | [195.241.69.171] |
| In-Reply-To | <2fa89ca32d0796866e0fe4121371b882.squirrel@webmail.lexicon.net> |
| References | <BANLkTikW_Yq9XL=rBxnsOAYjSjXXVk9MUA@mail.gmail.com> <2fa89ca32d0796866e0fe4121371b882.squirrel@webmail.lexicon.net> |
| From | Michiel Sikma <michiel@wedemandhtml.com> |
| Date | Thu, 12 May 2011 10:05:52 +0200 |
| Subject | Re: urllib2 request with binary file as payload |
| To | sjmachin@lexicon.net |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1452.1305187574.9059.python-list@python.org> (permalink) |
| Lines | 45 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1305187574 news.xs4all.nl 81483 [::ffff:82.94.164.166]:60836 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:5219 |
Show key headers only | View raw
> > 2.6 is expecting a string, according to the above. No mention of file. > Moreover it expects the data to be urlencoded. 2.7.1 docs say the same > thing. Are you sure you have shown the code that worked with 2.6? > > > -- > http://mail.python.org/mailman/listinfo/python-list > Yes, in fact I simply tried passing the file to the Request class without having checked the docs to see if I could even do that, but it worked. I also send an unencoded XML string a little bit earlier on. Maybe it no longer needs to be a urlencoded string as soon as you add a Content-Type header. Here's what happens when I put the HTTPHandler in debug mode and pass a file in 2.6: send: 'PUT /resumable/feeds/api/users/default/uploads?upload_id=[id]HTTP/1.1\r\nAccept-Encoding: identity\r\nContent-Length: 898801\r\nHost: uploads.gdata.youtube.com\r\nContent-Type: application/octet-stream\r\nConnection: close\r\nUser-Agent: Python-urllib/2.6\r\n\r\n' send: <open file 'file.mp4', mode 'rb' at 0x1005db580> sendIng a read()able A little while later: reply: 'HTTP/1.1 201 Created\r\n' [...etc] So it seems to work just fine, but 2.5 does indeed complain about this being an incorrect use of Request. Moreover, though I can't upgrade my Python from 2.5 I was able to compile another alongside it (latest stable 2.7) and use that with my code, and it worked just fine. Uploaded a 6GB file to Youtube this way. :) Michiel Sikma We Demand HTML http://wedemandhtml.com/ michiel@wedemandhtml.com
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: urllib2 request with binary file as payload Michiel Sikma <michiel@wedemandhtml.com> - 2011-05-12 10:05 +0200
csiph-web