There is no reason more than debugging for getAdapter().
I don't know benefit except debugging.
For example, "getConfig()" , "setUserAgent" and other method will also have great benefits to.
But current Zend_Http_Client has not these method.

And Unfortunatoly, getter's doc-comment is same as mutator.

Posted by Michael Stillwell (mjs) on 2009-10-22T02:25:55.000+0000

As I mentioned in ZF-8027 getAdapter() is useful when debugging. In my case something was setting the adapter to something unexpected, but without a getAdapter() there was no way to even determine the class/type of the adapter.

getAdapter() is also probably useful when using some of the test adapters. For example if you need to dynamically modify the next "response" that the adapter will give.

I'm not completely sure, but I don't think the getAdapter() should be in the business of creating an adapter if it doesn't already exist. (One reason: if this is the case, then there's no way to tell whether the adapter is already set.) I don't think it's necessary to check the type of the adapter since setAdapter() already does this. (i.e. the return type of getAdapter() will never be a lie, because there's no way to set the adapter to anything other than something that implements Zend_Http_Client_Adapter_Interface.)

However, I do think there is a problem arising from the patch in that if getAdapter() exists, all direct reads of $this->adapter (for example, in Zend_Http_Client's request() method) should be converted into reads of getAdapter() instead.

Regarding reason (1) above, I think the problem that calling methods on the adapter directly can lead to nonsensical results is more a consequence of the somewhat strange way the client uses the adapter rather than a problem that arises because getAdapter() exists.

I don't really understand (2).

Regarding (3), I think there probably should be a getConfig() method as well.

Posted by Michael Stillwell (mjs) on 2009-10-23T03:12:11.000+0000

Oh, and regarding why I can't extend Zend_Http_Client myself, and add a getAdapter() method to that: in my case the client is being built by a call to a factory object that I don't have any control over.