set svn:keywords property for proper keywords expansion
[plcapi.git] / pycurl / tests / test_post3.py
1 #! /usr/bin/env python
2 # -*- coding: iso-8859-1 -*-
3 # vi:ts=4:et
4 # $Id$
5
6 import urllib
7 POSTSTRING = urllib.urlencode({'field1':'value1', 'field2':'value2 with blanks', 'field3':'value3'})
8
9 class test:
10
11     def __init__(self):
12         self.finished = False
13
14     def read_cb(self, size):
15         assert len(POSTSTRING) <= size
16         if not self.finished:
17             self.finished = True
18             return POSTSTRING
19         else:
20             # Nothing more to read
21             return ""
22
23 import pycurl
24 c = pycurl.Curl()
25 t = test()
26 c.setopt(c.URL, 'http://pycurl.sourceforge.net/tests/testpostvars.php')
27 c.setopt(c.POST, 1)
28 c.setopt(c.POSTFIELDSIZE, len(POSTSTRING))
29 c.setopt(c.READFUNCTION, t.read_cb)
30 c.setopt(c.VERBOSE, 1)
31 c.perform()
32 c.close()