Example #1
0
 /**
  * {@inheritdoc}
  */
 public function upload(RequestInterface $request)
 {
     $this->headerParser->reset();
     $uri = $request->getUri();
     $ch = curl_init((string) $uri);
     $options = $this->optionsGenerator->generate($request);
     curl_setopt_array($ch, $options);
     $body = curl_exec($ch);
     if (0 !== curl_errno($ch)) {
         throw new SpeechKitException(curl_error($ch), curl_errno($ch));
     }
     list($status, $reason) = $this->headerParser->getStatusInfo();
     $headers = $this->headerParser->getHeaders();
     $body = \GuzzleHttp\Psr7\stream_for($body);
     return new Response($status, $headers, $body, '1.1', $reason);
 }
Example #2
0
 public function it_throws_when_connnection_error_happens(RequestInterface $request, OptionsGenerator $optionsGenerator)
 {
     $request->getUri()->willReturn('http://localhost:999999');
     $optionsGenerator->generate($request)->willReturn([CURLOPT_RETURNTRANSFER => true]);
     $this->shouldThrow('SpeechKit\\Exception\\SpeechKitException')->duringUpload($request);
 }