Exemple #1
0
 public function runInHttpMode($file)
 {
     $server = new HttpServer('localhost', 56789, $this->getFilePath($file));
     $server->start();
     $client = new HttpClient();
     $request = new HttpRequest(HttpRequestMethod::GET, new Url('localhost:56789'));
     $response = $client->send($request);
     $server->stop();
     return $response->getContent();
 }
Exemple #2
0
 public function test_create_client_with_options()
 {
     $options = new HttpClientOptions();
     $client = new HttpClient(null, $options);
     $this->assertTrue($client->getOptions() === $options);
 }
 public function test_send_request_to_unreachable_host()
 {
     $client = new HttpClient();
     $request = new HttpRequest(HttpRequestMethod::GET, new Url('http://foo.bar'));
     $this->setExpectedException(CurlException::class);
     $client->send($request);
 }
Exemple #4
0
 /**
  * @param IHttpRequest $httpRequest
  *
  * @return JsonResponse
  */
 public function send(IHttpRequest $httpRequest)
 {
     return JsonResponse::create(parent::send($httpRequest));
 }