[Zope3-Users] Send User-Agent header with
zope.testbrowser.browser.Browser
Jeff Kowalczyk
jtk at yahoo.com
Fri May 9 14:27:15 EDT 2008
Is there anything I need to do with the mech_browser attribute to send a
custom User-Agent header with zope.testbrowser.browser.Browser?
>>> from zope.testbrowser.browser import Browser
>>> b = Browser()
>>> b.addHeader('User-Agent', 'Zope Test Browser')
>>> b.open('http://localhost/')
Apache agent_logs reads: 'Python-urllib/2.5'
Setting the header on the mech_browser, also shows up as
'Python-urllib/2.5':
>>> b.mech_browser.request.add_header('User-Agent', 'Zope Test Browser')
>>> b.mech_browser.request.headers
{'User-agent': 'Zope Test Browser'}
>>> b.open('http://localhost/')
>>> b.mech_browser.request.headers
{}
Thanks,
Jeff
configuration:
non-system python-2.5, virtualenv, easy_install zope.testbrowser
More information about the Zope3-users
mailing list