[fw-core] [ZF2] Changes in /Zend/Http/Client break /Zend/Http/Client/Adapter/Proxy

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[fw-core] [ZF2] Changes in /Zend/Http/Client break /Zend/Http/Client/Adapter/Proxy

proofek
Hello,

I discovered todays that /Zend/Http/Client/Adapter/Proxy stopped working
and doesn't proxy request after the following change:

commit 0f5bf882080a126892c52bef603facbf1c6bd7b6
Author: Ralph Schindler <[hidden email]>
Date:   Fri Aug 19 10:17:13 2011 -0500

    Zend\Http
      - Various codeing standard cleanups, addition of docblocks
      - Added tests to ResponseTest for Zend\Http\Response
      - Started refactor of Cookies implementation


The code that has changed is:

public function setConfig($config = array())
{
    if ($config instanceof Config) {
        $config = $config->toArray();

    } elseif (!is_array($config)) {
        throw new Exception\InvalidArgumentException('Config parameter
is not valid');
    }

    /** Config Key Normalization */
    foreach ($config as $k => $v) {
        $this->config[str_replace(array('-', '_', ' ', '.'), '',
strtolower($k))] = $v; // replace w/ normalized
    }

    // Pass configuration options to the adapter if it exists
    if ($this->adapter instanceof Client\Adapter) {
        $this->adapter->setConfig($config);
    }

    return $this;
}

and basically removes underscores in options provided. The result is, that
options like http_proxy or http_user are changed to httpproxy, httpuser,
etc.

Initially I assumed that options naming convention is changing for ZF2
(hence my pull request - https://github.com/zendframework/zf2/pull/588),
but comments provided on the pull request makes me think that it's rather
the code in the Client broken. I am still a bit confused though - why would
you replace any characters provided in options array? It's an array, so I
guess valid options should be provided and they shouldn't need any post
processing. If I am wrong, what will be the way to fix it? Once I
understand it, I am more then happy to provide a patch to fix it.

Regards
--
Sebastian Marek
[hidden email]

Follow me online at:
Blog: http://criticallog.thornet.net/
Twitter: http://twitter.com/proofek
Linkedin: http://uk.linkedin.com/in/sebastianmarek
Ohloh: http://www.ohloh.net/accounts/proofek
<http://twitter.com/proofek>
Reply | Threaded
Open this post in threaded view
|

Re: [fw-core] [ZF2] Changes in /Zend/Http/Client break /Zend/Http/Client/Adapter/Proxy

weierophinney
Administrator
Sebastian --

Can you repost this to zf-contributors, please? That's where we discuss
the development of the framework itself.

I saw your PR earlier, and your comment to my reply, and I agree,
something's wrong here. We should work to fix it, and my inclination is
we keep the underscore separators.

-- Sebastian Marek <[hidden email]> wrote
(on Friday, 11 November 2011, 07:56 PM +0000):

> Hello,
>
> I discovered todays that /Zend/Http/Client/Adapter/Proxy stopped working
> and doesn't proxy request after the following change:
>
> commit 0f5bf882080a126892c52bef603facbf1c6bd7b6
> Author: Ralph Schindler <[hidden email]>
> Date:   Fri Aug 19 10:17:13 2011 -0500
>
>     Zend\Http
>       - Various codeing standard cleanups, addition of docblocks
>       - Added tests to ResponseTest for Zend\Http\Response
>       - Started refactor of Cookies implementation
>
>
> The code that has changed is:
>
> public function setConfig($config = array())
> {
>     if ($config instanceof Config) {
>         $config = $config->toArray();
>
>     } elseif (!is_array($config)) {
>         throw new Exception\InvalidArgumentException('Config parameter
> is not valid');
>     }
>
>     /** Config Key Normalization */
>     foreach ($config as $k => $v) {
>         $this->config[str_replace(array('-', '_', ' ', '.'), '',
> strtolower($k))] = $v; // replace w/ normalized
>     }
>
>     // Pass configuration options to the adapter if it exists
>     if ($this->adapter instanceof Client\Adapter) {
>         $this->adapter->setConfig($config);
>     }
>
>     return $this;
> }
>
> and basically removes underscores in options provided. The result is, that
> options like http_proxy or http_user are changed to httpproxy, httpuser,
> etc.
>
> Initially I assumed that options naming convention is changing for ZF2
> (hence my pull request - https://github.com/zendframework/zf2/pull/588),
> but comments provided on the pull request makes me think that it's rather
> the code in the Client broken. I am still a bit confused though - why would
> you replace any characters provided in options array? It's an array, so I
> guess valid options should be provided and they shouldn't need any post
> processing. If I am wrong, what will be the way to fix it? Once I
> understand it, I am more then happy to provide a patch to fix it.
>
> Regards
> --
> Sebastian Marek
> [hidden email]
>
> Follow me online at:
> Blog: http://criticallog.thornet.net/
> Twitter: http://twitter.com/proofek
> Linkedin: http://uk.linkedin.com/in/sebastianmarek
> Ohloh: http://www.ohloh.net/accounts/proofek
> <http://twitter.com/proofek>

--
Matthew Weier O'Phinney
Project Lead            | [hidden email]
Zend Framework          | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]