[twill] Twill and HTTP headers

Mike Orr sluggoster at gmail.com
Mon Jun 7 16:49:54 PDT 2010


Yes, I can print them, but what I want is for my Twill script to check
the header like it does with 'find'.  Abort if it doesn't match, and
not print anything if it does match.

On Mon, Jun 7, 2010 at 3:12 PM, Kevin Boers <KBoers at leapfrogonline.com> wrote:
> Hi, Mike,
> It's pretty easy to print the response headers using the info() method:
>>>> import twill.commands as twill
>>>> twill.go('http://path/to/json_file.json')
>>>> twill.info()
> Page information:
> URL: http://path/to/json_file.json
> HTTP code: 200
> Content type: application/json; charset=utf-8
> It's not super straightforward, but you can also grab the response headers
> from the browser object as well (for example, if you want to assert against
> them):
>>>> b = twill.get_browser()
>>>> b._browser._response.info().getheaders("content-type")
> ['application/json; charset=utf-8']
> Does that help?
> Cheers,
> Kevin
> On Jun 7, 2010, at 4:46 PM, Mike Orr wrote:
>
> Hi there, I've been using Twill for a few months and find it a great
> way to write a few basic tests to verify a site isn't broken. But I've
> come across what seems to be a missing feature. How can I test an HTTP
> header; e.g., to verify that a JSON response is actually
> "Content-type: application/json"?
>
> --
> Mike Orr <sluggoster at gmail.com>
>
> _______________________________________________
> twill mailing list
> twill at lists.idyll.org
> http://lists.idyll.org/listinfo/twill
>
> Kevin P. Boers
> QA Manager
> 847-440-8381
>
> Leapfrog Online
> 807 Greenwood
> Evanston, IL  60201
> Main 847-492-1968
> Fax  847-492-1990
> kboers at leapfrogonline.com
> www.leapfrogonline.com
>
> ________________________________
> CONFIDENTIALITY NOTE
> The document(s) accompanying this e-mail transmission, if any, and the
> e-mail transmittal message containing information from Leapfrog Online
> Customer Acquisition, LLC is confidential or privileged. The information is
> intended to be for the use of the individual(s) or entity(ies) named on this
> e-mail transmission message. If you are not the intended recipient, be aware
> that any disclosure, copying, distribution or use of the contents of this
> e-mail is prohibited. If you have received this e-mail in error, please
> immediately delete this e-mail and notify us by telephone of the error.
>
> _______________________________________________
> twill mailing list
> twill at lists.idyll.org
> http://lists.idyll.org/listinfo/twill
>
>



-- 
Mike Orr <sluggoster at gmail.com>



More information about the twill mailing list