Пример #1
0
 /**
  * @group ZF-8397
  */
 public function testIfMatchHttpHeaderIsResetEachRequest()
 {
     // Update an entry
     $etag = Etag::fromString('Etag: ABCD1234');
     $this->adapter->setResponse("HTTP/1.1 201 Created");
     $this->service->setMajorProtocolVersion(2);
     $entry = new App\Entry();
     $entry->link = array(new Extension\Link('http://www.example.com', 'edit', 'application/atom+xml'));
     $entry->setEtag($etag);
     $this->service->updateEntry($entry);
     // Get another entry without ETag set,
     // Previous value of If-Match HTTP header should not be sent
     $this->adapter->setResponse($this->httpEntrySample);
     $entry = $this->service->getEntry('http://www.example.com');
     $headers = $this->adapter->popRequest()->headers;
     $found = false;
     foreach ($headers as $header => $value) {
         if ($header == 'If-Match' && $value == $etag->getFieldValue()) {
             $found = true;
         }
     }
     $this->assertFalse($found, 'If-Match header found');
 }
Пример #2
0
 /**
  * Uploads changes in this entry to the server using Zend_Gdata_App
  *
  * @param boolean $dryRun Whether the transaction is dry run or not.
  * @param string|null $uri The URI to send requests to, or null if $data
  *        contains the URI.
  * @param string|null $className The name of the class that should we
  *        deserializing the server response. If null, then
  *        'Zend_Gdata_App_Entry' will be used.
  * @param array $extraHeaders Extra headers to add to the request, as an
  *        array of string-based key/value pairs.
  * @return \Zend\GData\App\Entry The updated entry
  * @throws \Zend\GData\App\Exception
  */
 public function save($dryRun = false, $uri = null, $className = null, $extraHeaders = array())
 {
     if ($dryRun == true) {
         $editLink = $this->getEditLink();
         if ($uri == null && $editLink !== null) {
             $uri = $editLink->getHref() . '?dry-run=true';
         }
         if ($uri === null) {
             throw new App\InvalidArgumentException('You must specify an URI which needs deleted.');
         }
         $service = new App($this->getHttpClient());
         return $service->updateEntry($this, $uri, $className, $extraHeaders);
     } else {
         parent::save($uri, $className, $extraHeaders);
     }
 }