ZF-8397: getEntry($anEntryLink) doesn't work after updateEntry($anotherEntryObject)

Description

Following code will throw 'Zend_Gdata_App_HttpException' exception with message 'Expected response code 200, got 412 Mismatch: etags =' ...


$client = Zend_Gdata_ClientLogin::getHttpClient('liz%40gmail.com', 'password', 'cp');
$gdata = new Zend_Gdata($client);
$gdata->setMajorProtocolVersion(2);

$firstEntryLink = 'http://google.com/m8/feeds/…';
$secondEntryLink = 'http://google.com/m8/feeds/…';

// Retrieve first entry
$firstEntry = $gdata->getEntry($firstEntryLink);
// Edit first entry and update
$firstEntry->setContent($gdata->newContent('Test content'));
$gdata->updateEntry($firstEntry);
// attempt to retrieve another entry will throw the exception
$secondEntry = $gdata->getEntry($secondEntryLink);

Google Api versions affected: 2,3 (version 1 does not support etags)

When $gdata->updateEntry() is called, 'If-Match' header with entry's current etag is set to the http client adapter. When $gdata->getEntry() is called afterwards http client's headers are reset with the following code:


        // Make sure the HTTP client object is 'clean' before making a request
        // In addition to standard headers to reset via resetParameters(),
        // also reset the Slug header
        $this->_httpClient->resetParameters();
        $this->_httpClient->setHeaders('Slug', null);

Though, in fact it doesn't make the HTTP client clean and we should manually reset all headers we don't need:


        // Make sure the HTTP client object is 'clean' before making a request
        // In addition to standard headers to reset via resetParameters(),
        // also reset the Slug and If-Match headers
        $this->_httpClient->resetParameters();
        $this->_httpClient->setHeaders(array('Slug', 'If-Match'));

Comments

Patch that resolves the issue

Alexander, Thanks for the patch, looks good.

One quick request though before I commit this: Would you be able to write a unit test to go along with this? (We require that any new code has 100% test coverage, or as close to that as possible.)

Trevor, you are welcome. Unit test is attached.

Thanks for the patch!

This has been committed and is fixed for the next mini release.

{quote} commit 301c97764025157007af3d42f95b5def81edc478 Author: tjohns <tjohns@44c647ce-9c0f-0410-b52a-842ac1e357ba> Date: Mon Dec 7 23:57:38 2009 +0000

ZF-8397: Make sure that any If-Match headers that are present are cleared after performing an HTTP request using Zend_Gdata_App.

This fixes a bug which prevented getEntry() from working after calling updateEntry().

Patch by: Alexander Steshenko (lcf)

git-svn-id: <a rel="nofollow" href="http://framework.zend.com/svn/framework/standard/trunk@19510">http://framework.zend.com/svn/framework/&hellip;</a> 44c647ce-9c0f-0410-b52a-842ac1e357ba

{quote}

{quote} commit f593b29cd792093a13de4a8aba52886b01a4b0a1 Author: tjohns <tjohns@44c647ce-9c0f-0410-b52a-842ac1e357ba> Date: Tue Dec 8 00:00:51 2009 +0000

Merge r19510 from trunk to release-1.9.

ZF-8397: Make sure that any If-Match headers that are present are cleared after performing an HTTP request using Zend_Gdata_App.

This fixes a bug which prevented getEntry() from working after calling updateEntry().

Patch by: Alexander Steshenko (lcf)

git-svn-id: <a rel="nofollow" href="http://framework.zend.com/svn/framework/standard/branches/release-1.9@19513">http://framework.zend.com/svn/framework/&hellip;</a> 44c647ce-9c0f-0410-b52a-842ac1e357ba

{quote}