File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -310,6 +310,30 @@ dedicated web crawler or scraper such as `Goutte`_::
310310 $openPullRequests = trim($browser->clickLink('Pull requests')->filter(
311311 '.table-list-header-toggle a:nth-child(1)'
312312 )->text());
313+
314+ Dealing with Headers
315+ ~~~~~~~~~~~~~~~~~~~~
316+
317+ The fifth parameter of `request() ` accepts an array of headers in the same format
318+ you'd see in a FastCGI request: all-upper-case, dashes replaced with underscores,
319+ prefixed with `HTTP_ `. Array keys are lower-cased, with `HTTP_ ` stripped, and
320+ underscores turned to dashes, before saving those headers to the request.
321+
322+ If you're making a request to an application that has special rules about header
323+ capitalization or punctuation, you'll want to override HttpBrowser's `getHeaders() `
324+ method, which takes a Request object and returns an asociative array of headers.
325+ For example::
326+
327+ protected function getHeaders(Request $request): array
328+ {
329+ $headers = parent::getHeaders($request);
330+ if (isset($request->getServer()['api_key'])) {
331+ $headers['api_key'] = $request->getServer()['api_key'];
332+ }
333+ return $headers;
334+ }
335+
336+ This override is available as of Symfony 5.2.
313337
314338Learn more
315339----------
You can’t perform that action at this time.
0 commit comments