开发者

retrieve application/json document with twill/mechanize in authenticated session

I need to retrieve a document with MIME type "application开发者_如何转开发/json". I'm using twill to log in to a site and when I attempt to go to the URL pointing to the JSON document and show it, I get this message:

'The HTTP header field "Accept" with value "text/html; */*" could not be parsed.'

I have tried changing the "Accept" field to "application/json" but still no dice.

Thanks!!


This is by no means the answer I'm looking for, but zope.testbrowser will do what I want.

The interface is slightly more complicated than twill, but not by much.

Still looking for a twill solution!


Looks like you have Accept: text/html; */* which seems syntactically wrong to me: per w3.org, the syntax is

    <field>  =    Accept: <entry> *[ , <entry> ]
    <entry>  =    <content type> *[ ; <param> ]
    <param>  =    <attr> = <float>
    <attr>   =    q / mxs / mxb
    <float>  =    <ANSI-C floating point text represntation>

so that */*, since it follows a semicolon rather than a comma, should be a <param>, but not in fact of the form <attr> = <float>. Did you mean to have a q=something, after the semicolon, and forgot to give it? Else, just text/html, */* -- i.e., with a comma, not a semicolon -- seems to be the right syntax.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜