[mod_python] Sending headers

Bo Lorentsen bl at netgroup.dk
Wed Feb 16 02:28:39 EST 2005


Chris Jackson wrote:

>Is there a mod_python equivalent of sending headers such as this PHP
>example using a header() method:
>
>  
>
Yeps, how about :

def request( req ):
    req.header_out[ 'WWW-Authentication' ] = 'Basic realm="My Realm"'

    req.write( 'Text to send if user hits Cancel buBasic realm="My 
Realm"tton' )

   return apache.OK

Is this what you was looking for  ?

><?php
>  if (!isset($_SERVER['PHP_AUTH_USER'])) {
>   header('WWW-Authenticate: Basic realm="My Realm"');
>   header('HTTP/1.0 401 Unauthorized');
>  
>
Hmm, this makes no sense to me.

>   echo 'Text to send if user hits Cancel buBasic realm="My Realm"tton';
>   exit;
>.....
>  
>
/BL


More information about the Mod_python mailing list