Parse an HTTP request Authorization header with Python

前端 未结 10 552
情书的邮戳
情书的邮戳 2020-12-30 06:47

I need to take a header like this:

 Authorization: Digest qop=\"chap\",
     realm=\"testrealm@host.com\",
     username=\"Foobear\",
     response=\"6629fae         


        
10条回答
  •  再見小時候
    2020-12-30 07:25

    Your original concept of using PyParsing would be the best approach. What you've implicitly asked for is something that requires a grammar... that is, a regular expression or simple parsing routine is always going to be brittle, and that sounds like it's something you're trying to avoid.

    It appears that getting pyparsing on google app engine is easy: How do I get PyParsing set up on the Google App Engine?

    So I'd go with that, and then implement the full HTTP authentication/authorization header support from rfc2617.

提交回复
热议问题