Saturday, July 6, 2013

Setting HTTP 401 header from a component.

Hi All,

Whats the right way to set a 401 header ?

Im currently using

        if (empty($_SERVER['PHP_AUTH_DIGEST'])) {
            $this->controller->header('HTTP/1.1 401 Unauthorized');
            $this->controller->header('WWW-Authenticate: Digest realm="'.$realm.'",qop="auth",nonce="'.$realm.'",opaque="'.$realm.'"');
            return $this->setStatus(ERRDIGEST);
        }


Which fills my debug.log with

2013-07-06 14:09:46 Notice: Notice (8): Undefined offset: 1 in [/opt/hd-1983/lib/Cake/Network/CakeResponse.php, line 526]
Trace:
CakeResponse::header() - CORE/Cake/Network/CakeResponse.php, line 526
Controller::header() - CORE/Cake/Controller/Controller.php, line 821
[snip...]

Cakephp : 2.2.3

Thanks.

Cheers
Richard

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: