curl-and-python

How can I get the data into the put request

From: Paulina Gajewska <gajapaula_at_interia.pl>
Date: Fri, 14 Oct 2011 17:13:56 +0200

Hi List!
How can I make this cURL example in pycurl?
curl -u admin:geoserver -XPUT -H 'Content-type: text/xml' \
  -d '<layer><defaultStyle><name>roads_style</name></defaultStyle></layer>' \
  http://localhost:8080/geoserver/rest/layers/roads

How can I get the data into the put request?

Here is my current code:
import pycurl
import cStringIO
data ='<layer><defaultStyle><name>roads_style</name></defaultStyle></layer>'
url = ‚http://localhost:8080/geoserver/rest/layers/roads%e2%80%99

response = cStringIO.StringIO()

c = pycurl.Curl()
c.setopt(c.POST, 1)
c.setopt(c.HTTPHEADER, ['Content-type: text/xml'])
c.setopt(c.USERPWD, "%s:%s" % ('admin','geoserver'))
c.setopt(c.URL,url)
c.setopt(c.WRITEFUNCTION, response.write)
c.perform()

Thank you for your help

Paulina

----------------------------------------------------------------
Twoj wlasny dom za 675 zl/m-c!
http://linkint.pl/f2a56

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2011-10-14