Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 1.6.0, 1.6.1, 1.6.2, 1.7.0, 1.7.1, 1.7.2, 1.7.3, 1.7.4, 1.7.5, 1.7.6, 1.7.7, 1.7.8, 1.8.0, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.9.0, 1.9.1, 1.9.2, 1.9.3, 1.9.4, 1.9.5, 1.9.6
-
Fix Version/s: 1.9.7
-
Component/s: Zend_Gdata
-
Labels:None
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://www.google.com/m8/feeds/contacts/liz%40gmail.com/base/1a137ef0bd1517a';
$secondEntryLink = 'http://www.google.com/m8/feeds/contacts/liz%40gmail.com/base/9da88df0d0beac0';
// 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'));
Patch that resolves the issue