Esempio n. 1
0
 /**
  * Send the request
  */
 public function send()
 {
     // make a request object
     $this->request = $this->client->createRequest($this->method, $this->host . $this->resource);
     // set headers
     foreach ($this->headers as $header => $value) {
         $this->request->setHeader($header, $value);
     }
     // set body
     if (!empty($this->body)) {
         $this->request->setBody($this->body);
     }
     try {
         // finally send the request
         $this->response = $this->client->send($this->request);
     } catch (BadResponseException $e) {
         $this->response = $this->request->getResponse();
     }
     $this->sent = true;
 }
Esempio n. 2
0
 /**
  * Function to set given file parameters
  * on the request
  *
  * @param array $params File parameters to set
  */
 public function setBody($body, $contentType = null)
 {
     if (method_exists($this->request, 'setBody')) {
         $this->request->setBody($body, $contentType);
     }
 }