ZF-12522: Adapter Proxy fails to add Proxy-Authorization header

Issue Type: Bug Created: 2013-02-14T11:16:26.000+0000 Last Updated: 2013-02-14T12:31:54.000+0000 Status: Resolved Fix version(s): - 1.12.2 (25/Feb/13)

Reporter: Dimitris Giotas (dgiotas) Assignee: Frank Brückner (frosch) Tags: - Zend_Http_Client

Related issues: Attachments:


When trying to add proxy authorization header the following code fails:

<pre class="highlight">
$hasProxyAuthHeader = false;
foreach ($headers as $k => $v) {
    if ($k == 'proxy-authorization' || preg_match("/^proxy-authorization:/i", $v) ) {
        $hasProxyAuthHeader = true;
if (!$hasProxyAuthHeader) {
    $headers[] = 'proxy-authorization: ' . Zend_Http_Client::encodeAuthHeader(
        $this->config['proxy_user'], $this->config['proxy_pass'], $this->config['proxy_auth']

The $headers array is of this type:

<pre class="highlight">
$headers = array(
                 'Content-length: 0'

According to PHP (…) if we compare an integer with a string, the string will always be returned as 0, so the first loop inside the foreach always returns true. Quick solution is to change the if statement:

<pre class="highlight">
if ($k == 'proxy-authorization' || preg_match("/^proxy-authorization:/i", $v) ) {

to convert $k to string:

<pre class="highlight">
if ((string) $k == 'proxy-authorization' || preg_match("/^proxy-authorization:/i", $v) ) {


Posted by Frank Brückner (frosch) on 2013-02-14T12:31:15.000+0000

Fixed on trunk (25260) and release-1.12 (25261)

Posted by Frank Brückner (frosch) on 2013-02-14T12:31:54.000+0000

@Dimitris Thanks for reporting.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.