Ejemplo n.º 1
0
 /**
  * Extracts the headers from the response, and saves them as object 
  * attributes. Additional name conversions are done where necessary.
  * 
  * @param Http $response
  */
 private function saveResponseHeaders(Http $response, $fillExtraIfNotFound = true)
 {
     foreach ($response->headers() as $header => $value) {
         if (isset($this->headerTranslate[$header])) {
             // This header needs to be translated
             $property = $this->headerTranslate[$header];
             // Are there multiple properties that need to be set?
             if (is_array($property)) {
                 foreach ($property as $subProperty) {
                     $this->{$subProperty} = $value;
                 }
             } else {
                 $this->{$property} = $value;
             }
         } elseif ($fillExtraIfNotFound === true) {
             // Otherwise, stock extra headers
             $this->extra_headers[$header] = $value;
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Given an Http response object, converts the appropriate headers
  * to metadata
  *
  * @param  OpenCloud\Common\Request\Response\Http
  * @return void
  */
 public function getMetadata(Http $response)
 {
     $this->metadata = new Metadata();
     $this->metadata->setArray($response->headers(), $this->prefix());
 }