Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #42489

Re: Curl and python httplib?

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'url:pypi': 0.03; 'from:addr:yahoo.co.uk': 0.04; 'skip:p 60': 0.07; '#print': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'satisfy': 0.09; 'url:localhost': 0.09; '307': 0.16; 'guys,': 0.16; 'httplib': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'server:': 0.16; 'urllib': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'module': 0.19; 'import': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'url:moin': 0.24; 'skip:" 40': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'requests': 0.31; 'url:wiki': 0.31; 'url:python': 0.33; 'url:non-standard http port': 0.33; 'skip:d 20': 0.34; 'problem': 0.35; "can't": 0.35; 'knows': 0.35; 'anybody': 0.35; 'but': 0.35; 'subject:?': 0.36; 'url:org': 0.36; 'project': 0.37; 'server': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'read': 0.60; 'skip:c 50': 0.60; 'location:': 0.61; "you're": 0.61; '500': 0.70; 'curl': 0.84; "skip:' 130": 0.84; 'url:47': 0.84; 'url:v1': 0.84; 'url:op': 0.91; 'why?': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Mark Lawrence <breamoreboy@yahoo.co.uk>
Subject Re: Curl and python httplib?
Date Mon, 01 Apr 2013 20:33:58 +0100
References <tencent_1864B149374D92FA7DC0902F@qq.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host host-92-18-43-197.as13285.net
User-Agent Mozilla/5.0 (Windows NT 6.0; rv:17.0) Gecko/20130307 Thunderbird/17.0.4
In-Reply-To <tencent_1864B149374D92FA7DC0902F@qq.com>
X-Antivirus avast! (VPS 130401-0, 01/04/2013), Outbound message
X-Antivirus-Status Clean
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.12.1364844730.17481.python-list@python.org> (permalink)
Lines 59
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1364844730 news.xs4all.nl 6899 [2001:888:2000:d::a6]:40019
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:42489

Show key headers only | View raw


On 30/03/2013 05:08, Сѧ԰PHP wrote:
> Guys,
>
> I take a project that need send request to Hadoop by curl.
> But now, the curl and pycurl can't satisfy my project. So i need use the
> powerful httplib.
> But failed.
>
> *my curl request:*
> curl -i -X PUT "http://localhost:50070/webhdfs/v1/levi/7?op=CREATE"
>
> *my return:*
> HTTP/1.1 307 TEMPORARY_REDIRECT
> Content-Type: application/octet-stream
> Location:
> http://58.53.211.47:50075/webhdfs/v1/levi/7?op=CREATE&overwrite=false
> Content-Length: 0
> Server: Jetty(6.1.26)
>
> *Now, i change the curl request to httplib:*
> import httplib
> import urllib
>
> params=urllib.urlencode({"@op":"CREATE","@user.name":"levi"})
> headers={"Content-type": "application/x-www-form-urlencoded","Accept":
> "text/plain"}
> conn=httplib.HTTPConnection("localhost:50070")
> conn.request("PUT","/webhdfs/v1/levi/7.txt",params,headers)
> response=conn.getresponse()
> print response.status, response.reason
> data=response.read()
> print data
> conn.close()
>
> *But it failed:*
> #print response.status, response.reason
> 500 Internal Server Error
> #print data
> '{"RemoteException":{"exception":"WebApplicationException","javaClassName":"javax.ws.rs.WebApplicationException","message":null}}'
>
> Who knows why? It's OK when i use curl, so where is the problem in
> httplib method?
> Or some other reasons?
> Who can help me change the curl request to httplib edition?
>
> TIA
> Levi
>
>

Try the requests module https://pypi.python.org/pypi/requests/ as if I 
can successfuly use it anybody can :)

-- 
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.

Mark Lawrence

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Curl and python httplib? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-04-01 20:33 +0100
  Re: Curl and python httplib? vasudevram <vasudevram@gmail.com> - 2013-04-01 15:07 -0700
  Re: Curl and python httplib? vasudevram <vasudevram@gmail.com> - 2013-04-01 15:07 -0700

csiph-web