Skip to content

Commit fca8878

Browse files
authored
Merge pull request #6208 from kenjis/fix-docs-response
docs: replace $response with $this->response in response.rst
2 parents b306fbc + 7c05e9f commit fca8878

File tree

9 files changed

+31
-31
lines changed

9 files changed

+31
-31
lines changed

user_guide_src/source/outgoing/response.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ When enabled, the response object will contain an instance of ``CodeIgniter\HTTP
147147
values set in **app/Config/ContentSecurityPolicy.php** are applied to that instance, and if no changes are
148148
needed during runtime, then the correctly formatted header is sent and you're all done.
149149

150-
With CSP enabled, two header lines are added to the HTTP response: a Content-Security-Policy header, with
150+
With CSP enabled, two header lines are added to the HTTP response: a **Content-Security-Policy** header, with
151151
policies identifying content types or origins that are explicitly allowed for different
152-
contexts, and a Content-Security-Policy-Report-Only header, which identifies content types
152+
contexts, and a **Content-Security-Policy-Report-Only** header, which identifies content types
153153
or origins that will be allowed but which will also be reported to the destination
154154
of your choice.
155155

@@ -161,7 +161,7 @@ call basis, by providing an optional second parameter to the adding method call.
161161
Runtime Configuration
162162
---------------------
163163

164-
If your application needs to make changes at run-time, you can access the instance at ``$response->CSP``. The
164+
If your application needs to make changes at run-time, you can access the instance at ``$this->response->CSP`` in your controllers. The
165165
class holds a number of methods that map pretty clearly to the appropriate header value that you need to set.
166166
Examples are shown below, with different combinations of parameters, though all accept either a directive
167167
name or an array of them:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?php
22

3-
$response->setHeader('Location', 'http://example.com')
3+
$this->response->setHeader('Location', 'http://example.com')
44
->setHeader('WWW-Authenticate', 'Negotiate');
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?php
22

3-
$response->setHeader('Cache-Control', 'no-cache')
3+
$this->response->setHeader('Cache-Control', 'no-cache')
44
->appendHeader('Cache-Control', 'must-revalidate');
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<?php
22

3-
$response->removeHeader('Location');
3+
$this->response->removeHeader('Location');

user_guide_src/source/outgoing/response/007.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
$data = 'Here is some text!';
44
$name = 'mytext.txt';
55

6-
return $response->download($name, $data);
6+
return $this->response->download($name, $data);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
<?php
22

33
// Contents of photo.jpg will be automatically read
4-
return $response->download('/path/to/photo.jpg', null);
4+
return $this->response->download('/path/to/photo.jpg', null);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<?php
22

3-
return $response->download('awkwardEncryptedFileName.fakeExt', null)->setFileName('expenses.csv');
3+
return $this->response->download('awkwardEncryptedFileName.fakeExt', null)->setFileName('expenses.csv');
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
<?php
22

33
// specify the default directive treatment
4-
$response->CSP->reportOnly(false);
4+
$this->response->CSP->reportOnly(false);
55

66
// specify the origin to use if none provided for a directive
7-
$response->CSP->setDefaultSrc('cdn.example.com');
7+
$this->response->CSP->setDefaultSrc('cdn.example.com');
88

99
// specify the URL that "report-only" reports get sent to
10-
$response->CSP->setReportURI('http://example.com/csp/reports');
10+
$this->response->CSP->setReportURI('http://example.com/csp/reports');
1111

1212
// specify that HTTP requests be upgraded to HTTPS
13-
$response->CSP->upgradeInsecureRequests(true);
13+
$this->response->CSP->upgradeInsecureRequests(true);
1414

1515
// add types or origins to CSP directives
1616
// assuming that the default treatment is to block rather than just report
17-
$response->CSP->addBaseURI('example.com', true); // report only
18-
$response->CSP->addChildSrc('https://youtube.com'); // blocked
19-
$response->CSP->addConnectSrc('https://*.facebook.com', false); // blocked
20-
$response->CSP->addFontSrc('fonts.example.com');
21-
$response->CSP->addFormAction('self');
22-
$response->CSP->addFrameAncestor('none', true); // report this one
23-
$response->CSP->addImageSrc('cdn.example.com');
24-
$response->CSP->addMediaSrc('cdn.example.com');
25-
$response->CSP->addManifestSrc('cdn.example.com');
26-
$response->CSP->addObjectSrc('cdn.example.com', false); // reject from here
27-
$response->CSP->addPluginType('application/pdf', false); // reject this media type
28-
$response->CSP->addScriptSrc('scripts.example.com', true); // allow but report requests from here
29-
$response->CSP->addStyleSrc('css.example.com');
30-
$response->CSP->addSandbox(['allow-forms', 'allow-scripts']);
17+
$this->response->CSP->addBaseURI('example.com', true); // report only
18+
$this->response->CSP->addChildSrc('https://youtube.com'); // blocked
19+
$this->response->CSP->addConnectSrc('https://*.facebook.com', false); // blocked
20+
$this->response->CSP->addFontSrc('fonts.example.com');
21+
$this->response->CSP->addFormAction('self');
22+
$this->response->CSP->addFrameAncestor('none', true); // report this one
23+
$this->response->CSP->addImageSrc('cdn.example.com');
24+
$this->response->CSP->addMediaSrc('cdn.example.com');
25+
$this->response->CSP->addManifestSrc('cdn.example.com');
26+
$this->response->CSP->addObjectSrc('cdn.example.com', false); // reject from here
27+
$this->response->CSP->addPluginType('application/pdf', false); // reject this media type
28+
$this->response->CSP->addScriptSrc('scripts.example.com', true); // allow but report requests from here
29+
$this->response->CSP->addStyleSrc('css.example.com');
30+
$this->response->CSP->addSandbox(['allow-forms', 'allow-scripts']);
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
$response->addChildSrc('https://youtube.com'); // allowed
4-
$response->reportOnly(true);
5-
$response->addChildSrc('https://metube.com'); // allowed but reported
6-
$response->addChildSrc('https://ourtube.com', false); // allowed
3+
$this->response->CSP->addChildSrc('https://youtube.com'); // allowed
4+
$this->response->CSP->reportOnly(true);
5+
$this->response->CSP->addChildSrc('https://metube.com'); // allowed but reported
6+
$this->response->CSP->addChildSrc('https://ourtube.com', false); // allowed

0 commit comments

Comments
 (0)