PSR standards · Question 9 of 12

A service calls an external API with the TYPO3 RequestFactory: $this->requestFactory->request($url, 'GET', ['timeout' => 5]). Which statements are true?

2 answers are correct. Medium

Show answer

Answer

  • B If the API responds with 404 or 500, Guzzle throws an exception by default that has to be caught
  • D The result is a PSR-7 response, and the content is read e.g. with (string)$response->getBody()

Explanation

request() passes the request to a Guzzle client that is preconfigured with the settings from $GLOBALS['TYPO3_CONF_VARS']['HTTP'], such as proxy and headers. Options in the third parameter add to or override them for this call. Globally, timeout is 0, i.e. unlimited, so a custom limit is worthwhile. Since http_errors stays enabled, status codes from 400 lead to a RequestException.

Certifications & exams

Which exam comes next?

You can already practise for 19 exams, and 21 are up for a vote. See all certifications with their official information, cast your vote or suggest your exam.

See all certifications