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


Groups > comp.lang.python > #42117

Curl and python httplib?

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <xxy-php@qq.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status UNSURE 0.298
X-Spam-Level **
X-Spam-Evidence '*H*': 0.58; '*S*': 0.18; 'skip:p 60': 0.07; '#print': 0.09; 'failed:': 0.09; 'satisfy': 0.09; 'url:localhost': 0.09; '307': 0.16; 'guys,': 0.16; 'httplib': 0.16; 'server:': 0.16; 'skip:d 130': 0.16; 'urllib': 0.16; 'subject:python': 0.16; 'import': 0.22; 'print': 0.22; 'error': 0.23; 'skip:" 40': 0.26; 'to:name:python-list': 0.33; 'url:non-standard http port': 0.33; 'skip:d 20': 0.34; 'problem': 0.35; "can't": 0.35; 'knows': 0.35; 'but': 0.35; 'subject:?': 0.36; 'project': 0.37; 'server': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:c 50': 0.60; 'location:': 0.61; 'skip:a 30': 0.61; 'skip:t 30': 0.61; 'skip:r 40': 0.68; '500': 0.70; 'curl': 0.84; 'from:addr:qq.com': 0.84; 'message-id:@qq.com': 0.84; 'received:qq.com': 0.84; "skip:' 130": 0.84; 'skip:p 80': 0.84; 'url:47': 0.84; 'url:v1': 0.84; 'x-mailer:qqmail 2.x': 0.84; 'request:': 0.91; 'url:op': 0.91; 'why?': 0.91; 'received:183': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s0907; t=1364441131; bh=4SqqsoX2uA8FaVyyAlNJAm5kGJGhmBM3LigQ1EiQ4fQ=; h=X-QQ-SSF:X-HAS-ATTACH:X-QQ-BUSINESS-ORIGIN:X-Originating-IP: X-QQ-STYLE:X-QQ-mid:From:To:Subject:Mime-Version:Content-Type: Content-Transfer-Encoding:Date:X-Priority:Message-ID:X-QQ-MIME: X-Mailer:X-QQ-Mailer; b=V8HZCVinl8g8fY9FmD9cVInlglXIBi9/p4DyO22M84FJ+ey118EA3NaQwA63kkKSx 0MrqbF4cQceqjLS+57p5jXQ4B2L6NVn/5U+wCB3PF2bTWzirdZ7ThJezJYcTPq+
X-QQ-SSF 0000000000000030000000000000000
X-HAS-ATTACH no
X-QQ-BUSINESS-ORIGIN 2
X-Originating-IP 221.234.160.55
X-QQ-STYLE
X-QQ-mid webmail579t1364439283t3556627
From "Сѧ԰PHP" <xxy-php@qq.com>
To "python-list" <python-list@python.org>
Subject Curl and python httplib?
Mime-Version 1.0
Content-Type multipart/alternative; boundary="----=_NextPart_5153B0F3_0A8E90B0_368B6373"
Content-Transfer-Encoding 8Bit
Date Thu, 28 Mar 2013 10:54:43 +0800
X-Priority 3
X-QQ-MIME TCMime 1.0 by Tencent
X-Mailer QQMail 2.x
X-QQ-Mailer QQMail 2.x
X-Mailman-Approved-At Thu, 28 Mar 2013 12:26:39 +0100
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.3871.1364470001.2939.python-list@python.org> (permalink)
Lines 100
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1364470001 news.xs4all.nl 6934 [2001:888:2000:d::a6]:46005
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:42117

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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

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


Thread

Curl and python httplib? "Сѧ԰PHP" <xxy-php@qq.com> - 2013-03-28 10:54 +0800

csiph-web