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


Groups > comp.lang.python > #42520

Re: Curl and python httplib?

Path csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <vasudevram@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.012
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'url:pypi': 0.03; 'skip:p 60': 0.07; '#print': 0.09; 'lawrence': 0.09; 'satisfy': 0.09; 'to:addr:comp.lang.python': 0.09; 'url:localhost': 0.09; 'cc:addr :python-list': 0.11; '307': 0.16; 'guys,': 0.16; 'httplib': 0.16; 'server:': 0.16; 'urllib': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'module': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'url:moin': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'skip:" 40': 0.26; '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; 'received:209.85': 0.35; 'knows': 0.35; 'anybody': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'url:org': 0.36; 'project': 0.37; 'received:209': 0.37; 'server': 0.38; '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; '2013': 0.98
X-Received by 10.50.53.232 with SMTP id e8mr1342978igp.14.1364854061062; Mon, 01 Apr 2013 15:07:41 -0700 (PDT)
Newsgroups comp.lang.python
Date Mon, 1 Apr 2013 15:07:40 -0700 (PDT)
In-Reply-To <mailman.12.1364844730.17481.python-list@python.org>
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=14.96.164.226; posting-account=9tO8owkAAAA3FGTpR0gRxfE7SAV9In1Y
References <tencent_1864B149374D92FA7DC0902F@qq.com> <mailman.12.1364844730.17481.python-list@python.org>
User-Agent G2/1.0
X-Google-Web-Client true
X-Google-IP 14.96.164.226
MIME-Version 1.0
Subject Re: Curl and python httplib?
From vasudevram <vasudevram@gmail.com>
To comp.lang.python@googlegroups.com
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Cc python-list@python.org
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>
Message-ID <mailman.25.1364856587.17481.python-list@python.org> (permalink)
Lines 125
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1364856587 news.xs4all.nl 6962 [2001:888:2000:d::a6]:39704
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:42520

Show key headers only | View raw


On Tuesday, April 2, 2013 1:03:58 AM UTC+5:30, Mark Lawrence wrote:
> 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

Or try httplib2

GIYF

Back to comp.lang.python | Previous | NextPrevious 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