From 67b08ad30bce20e2a023c80e9feebf0a0c3bfabf Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Fri, 8 Jul 2022 15:48:35 +0200 Subject: [PATCH] [BrowserKit] Add response fetch to BrowserKit documentation --- components/browser_kit.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/components/browser_kit.rst b/components/browser_kit.rst index 76c0e33d5e1..e89f98f97e2 100644 --- a/components/browser_kit.rst +++ b/components/browser_kit.rst @@ -321,6 +321,19 @@ dedicated web crawler or scraper such as `Goutte`_:: The feature to make external HTTP requests was introduced in Symfony 4.3. +Dealing with HTTP responses +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +When using the BrowserKit component, you may need to deal with responses of +the requests you made. To do so, you need to call the ``getResponse()`` +method of the ``HttpBrowser`` object. This method retrieves the last response +the browser received:: + + $browser = new HttpBrowser(HttpClient::create()); + + $browser->request('GET', 'https://foo.com'); + $response = $browser->getResponse(); + Learn more ----------