Skip to content

Commit 8763e61

Browse files
author
Thomas Ploch
committed
Added example of non standard 'X-Requested-With' HTTP header.
This example is giving an example on how to add a non standard header, and as well reminding the user to add a 'HTTP_' prefix, so the custom header gets sent.
1 parent e6aae29 commit 8763e61

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

book/testing.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,17 +235,19 @@ document::
235235
)
236236

237237
The ``server`` array is the raw values that you'd expect to normally
238-
find in the PHP `$_SERVER`_ superglobal. For example, to set the `Content-Type`
239-
and `Referer` HTTP headers, you'd pass the following::
238+
find in the PHP `$_SERVER`_ superglobal. For example, to set the `Content-Type`,
239+
`Referer` and `X-Requested-With' HTTP headers, you'd pass the following (mind
240+
the `HTTP_` prefix for non standard headers)::
240241

241242
$client->request(
242243
'GET',
243244
'/demo/hello/Fabien',
244245
array(),
245246
array(),
246247
array(
247-
'CONTENT_TYPE' => 'application/json',
248-
'HTTP_REFERER' => '/foo/bar',
248+
'CONTENT_TYPE' => 'application/json',
249+
'HTTP_REFERER' => '/foo/bar',
250+
'HTTP_X-Requested-With' => 'XMLHttpRequest'
249251
)
250252
);
251253

0 commit comments

Comments
 (0)