/** * Validate response model after processing * @throws ValidationException * @override */ protected function process() { parent::process(); if ($this[AbstractCommand::DISABLE_VALIDATION]) { // skipping validation in all cases return; } if (!$this->result instanceof Model) { // result is not a model - no way to validate return; } $errors = array(); $validator = SchemaValidator::getInstance(); // validate parameters present $schema = $this->result->getStructure(); $value = $this->result->toArray(); if (!$validator->validate($schema, $value)) { $errors = $validator->getErrors(); } // @todo validate additional parameters? // $schema->getAdditionalProperties() ); if ($errors) { $e = new ValidationException('Response failed model validation: ' . implode("\n", $errors)); $e->setErrors($errors); throw $e; } }
/** * {@inheritdoc} */ protected function process() { parent::process(); // Set the GetObject URL if using the PutObject operation if ($this->result instanceof Model && $this->getName() == 'PutObject') { $this->result->set('ObjectURL', $this->getRequest()->getUrl()); } }
protected function process() { parent::process(); $response = $this->request->getResponse(); $links = []; if ($response->hasHeader('Link')) { $linkParser = new LinkParser(); $links = $linkParser->parseLinkHeader($response->getHeader('Link')); } $this->result = new Collection($this->result, $links, $this->getClient()); }
/** * {@inheritdoc} */ protected function process() { $request = $this->getRequest(); $response = $this->getResponse(); // Dispatch an error if a 301 redirect occurred if ($response->getStatusCode() == 301) { $this->getClient()->getEventDispatcher()->dispatch('request.error', new Event(array('request' => $this->getRequest(), 'response' => $response))); } parent::process(); // Set the GetObject URL if using the PutObject operation if ($this->result instanceof Model && $this->getName() == 'PutObject') { $this->result->set('ObjectURL', $request->getUrl()); } }
/** * {@inheritdoc} */ protected function process() { $request = $this->getRequest(); $response = $this->getResponse(); // Dispatch an error if a 301 redirect occurred if ($response->getStatusCode() == 301) { $this->getClient()->getEventDispatcher()->dispatch('request.error', new Event(array('request' => $this->getRequest(), 'response' => $response))); } parent::process(); // Set the GetObject URL if using the PutObject operation if ($this->result instanceof Model && $this->getName() == 'PutObject') { $this->result->set('ObjectURL', $request->getUrl()); } if ($this->result instanceof Model && $this->getName() == 'GetObject') { $npos = strpos($response, "\n\r"); $head = substr($response, 0, $npos); COMMONLOG(DEBUG, "receive head:%s", $head); } else { COMMONLOG(DEBUG, "receive msg:%s", $response); } COMMONLOG(INFO, "http request:status:%d, code:, message:", $response->getStatusCode()); }
protected function process() { parent::process(); }