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(); }
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); }
/** * @param IHttpRequest $httpRequest * * @return JsonResponse */ public function send(IHttpRequest $httpRequest) { return JsonResponse::create(parent::send($httpRequest)); }