FAQ
I have a CGI server class derived from
BaseHTTPServer.BaseHTTPRequestHandler
which needs to get a username and passwd from a client.
This is fine unless the client is Internet Explorer - which I
understand only sends a username/passwd when challenged.
I have code something like:

if decode_authorization(self.headers):
....
else:
self.send_response(401)
self.end_headers()
return

But IE ingnores it, if I use send_error() IE prints the error message
instead of sending the authorization.

Any ideas ?

Search Discussions

  • Andrew Clover at Mar 24, 2004 at 8:50 pm

    mgb at mgbeckett.com (Martin Beckett) wrote:

    self.send_response(401)
    self.end_headers()
    return
    Don't know about BaseHTTPServer in particular, but in general 401 must be
    used in conjunction with the WWW-Authenticate response header, or the browser
    won't know what kind of authentication to send.

    self.send_header('WWW-Authenticate', 'basic realm="Fab site"')

    --
    Andrew Clover
    mailto:and at doxdesk.com
    http://www.doxdesk.com/
  • Martin Beckett at Mar 25, 2004 at 11:18 am

    Don't know about BaseHTTPServer in particular, but in general 401 must be
    used in conjunction with the WWW-Authenticate response header, or the browser
    won't know what kind of authentication to send.

    self.send_header('WWW-Authenticate', 'basic realm="Fab site"')
    Thank you that works - specifically:

    self.send_response(401)
    self.send_header('WWW-Authenticate','basic')
    self.end_headers

    And to help other searches: Internet Explorer force send username
    password authentication AUTHORIZATION

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedMar 24, '04 at 12:46p
activeMar 25, '04 at 11:18a
posts3
users2
websitepython.org

2 users in discussion

Martin Beckett: 2 posts Andrew Clover: 1 post

People

Translate

site design / logo © 2022 Grokbase