set svn:keywords property for proper keywords expansion
[plcapi.git] / pycurl / tests / test_cb.py
1 #! /usr/bin/env python
2 # -*- coding: iso-8859-1 -*-
3 # vi:ts=4:et
4 # $Id$
5
6 import sys
7 import pycurl
8
9 ## Callback function invoked when body data is ready
10 def body(buf):
11     # Print body data to stdout
12     sys.stdout.write(buf)
13
14 ## Callback function invoked when header data is ready
15 def header(buf):
16     # Print header data to stderr
17     sys.stderr.write(buf)
18
19 c = pycurl.Curl()
20 c.setopt(pycurl.URL, 'http://www.python.org/')
21 c.setopt(pycurl.WRITEFUNCTION, body)
22 c.setopt(pycurl.HEADERFUNCTION, header)
23 c.setopt(pycurl.FOLLOWLOCATION, 1)
24 c.setopt(pycurl.MAXREDIRS, 5)
25 c.perform()
26 c.setopt(pycurl.URL, 'http://curl.haxx.se/')
27 c.perform()
28 c.close()