~ntt-pf-lab/nova/monkey_patch_notification

« back to all changes in this revision

Viewing changes to vendor/Twisted-10.0.0/doc/web/howto/listings/client/sendbody.py

  • Committer: Jesse Andrews
  • Date: 2010-05-28 06:05:26 UTC
  • Revision ID: git-v1:bf6e6e718cdc7488e2da87b21e258ccc065fe499
initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from twisted.internet import reactor
 
2
from twisted.web.client import Agent
 
3
from twisted.web.http_headers import Headers
 
4
 
 
5
from stringprod import StringProducer
 
6
 
 
7
agent = Agent(reactor)
 
8
body = StringProducer("hello, world")
 
9
d = agent.request(
 
10
    'GET',
 
11
    'http://example.com/',
 
12
    Headers({'User-Agent': ['Twisted Web Client Example'],
 
13
             'Content-Type': ['text/x-greeting']}),
 
14
    body)
 
15
 
 
16
def cbResponse(ignored):
 
17
    print 'Response received'
 
18
d.addCallback(cbResponse)
 
19
 
 
20
def cbShutdown(ignored):
 
21
    reactor.stop()
 
22
d.addBoth(cbShutdown)
 
23
 
 
24
reactor.run()