diff --git a/docs/src/response_cookies/tutorial001.py b/docs/src/response_cookies/tutorial001.py
new file mode 100644
index 000000000..badc2fcc9
--- /dev/null
+++ b/docs/src/response_cookies/tutorial001.py
@@ -0,0 +1,12 @@
+from fastapi import FastAPI
+from starlette.responses import JSONResponse
+
+app = FastAPI()
+
+
+@app.post("/cookie/")
+def create_cookie():
+ content = {"message": "Come to the dark side, we have cookies"}
+ response = JSONResponse(content=content)
+ response.set_cookie(key="fakesession", value="fake-cookie-session-value")
+ return response
diff --git a/docs/src/response_headers/tutorial001.py b/docs/src/response_headers/tutorial001.py
new file mode 100644
index 000000000..8aad084b6
--- /dev/null
+++ b/docs/src/response_headers/tutorial001.py
@@ -0,0 +1,11 @@
+from fastapi import FastAPI
+from starlette.responses import JSONResponse
+
+app = FastAPI()
+
+
+@app.get("/headers/")
+def get_headers():
+ content = {"message": "Hello World"}
+ headers = {"X-Cat-Dog": "alone in the world", "Content-Language": "en-US"}
+ return JSONResponse(content=content, headers=headers)
diff --git a/docs/tutorial/middleware.md b/docs/tutorial/middleware.md
index f7d0adf47..f3a904d61 100644
--- a/docs/tutorial/middleware.md
+++ b/docs/tutorial/middleware.md
@@ -28,6 +28,12 @@ The middleware function receives:
!!! tip
This technique is used in the tutorial about SQL (Relational) Databases.
+
+!!! tip
+ Have in mind that custom proprietary headers can be added using the 'X-' prefix.
+
+ But if you have custom headers that you want a client in a browser to be able to see, you need to add them to your CORS configurations, using the parameter `expose_headers` documented in Starlette's CORS docs.
+
### Before and after the `response`
You can add code to be run with the `request`, before any *path operation* receives it.
diff --git a/docs/tutorial/response-cookies.md b/docs/tutorial/response-cookies.md
new file mode 100644
index 000000000..c36587c49
--- /dev/null
+++ b/docs/tutorial/response-cookies.md
@@ -0,0 +1,13 @@
+You can create (set) Cookies in your response.
+
+To do that, you can create a response as described in Return a Response directly.
+
+Then set Cookies in it, and then return it:
+
+```Python hl_lines="10 11 12"
+{!./src/response_cookies/tutorial001.py!}
+```
+
+## More info
+
+To see all the available parameters and options, check the documentation in Starlette.
diff --git a/docs/tutorial/response-headers.md b/docs/tutorial/response-headers.md
new file mode 100644
index 000000000..b7b1c5557
--- /dev/null
+++ b/docs/tutorial/response-headers.md
@@ -0,0 +1,12 @@
+You can add headers to your response.
+
+Create a response as described in Return a Response directly and pass the headers as an additional parameter:
+
+```Python hl_lines="10 11 12"
+{!./src/response_headers/tutorial001.py!}
+```
+
+!!! tip
+ Have in mind that custom proprietary headers can be added using the 'X-' prefix.
+
+ But if you have custom headers that you want a client in a browser to be able to see, you need to add them to your CORS configurations, using the parameter `expose_headers` documented in Starlette's CORS docs.
diff --git a/mkdocs.yml b/mkdocs.yml
index b53936384..57712ec12 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -48,6 +48,8 @@ nav:
- Return a Response directly: 'tutorial/response-directly.md'
- Custom Response Class: 'tutorial/custom-response.md'
- Additional Responses in OpenAPI: 'tutorial/additional-responses.md'
+ - Response Cookies: 'tutorial/response-cookies.md'
+ - Response Headers: 'tutorial/response-headers.md'
- Dependencies:
- First Steps: 'tutorial/dependencies/first-steps.md'
- Classes as Dependencies: 'tutorial/dependencies/classes-as-dependencies.md'
diff --git a/tests/test_tutorial/test_response_cookies/__init__.py b/tests/test_tutorial/test_response_cookies/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/tests/test_tutorial/test_response_cookies/test_tutorial001.py b/tests/test_tutorial/test_response_cookies/test_tutorial001.py
new file mode 100644
index 000000000..f67091900
--- /dev/null
+++ b/tests/test_tutorial/test_response_cookies/test_tutorial001.py
@@ -0,0 +1,12 @@
+from starlette.testclient import TestClient
+
+from response_cookies.tutorial001 import app
+
+client = TestClient(app)
+
+
+def test_path_operation():
+ response = client.post("/cookie/")
+ assert response.status_code == 200
+ assert response.json() == {"message": "Come to the dark side, we have cookies"}
+ assert response.cookies["fakesession"] == "fake-cookie-session-value"
diff --git a/tests/test_tutorial/test_response_headers/__init__.py b/tests/test_tutorial/test_response_headers/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/tests/test_tutorial/test_response_headers/test_tutorial001.py b/tests/test_tutorial/test_response_headers/test_tutorial001.py
new file mode 100644
index 000000000..9a3d172bb
--- /dev/null
+++ b/tests/test_tutorial/test_response_headers/test_tutorial001.py
@@ -0,0 +1,13 @@
+from starlette.testclient import TestClient
+
+from response_headers.tutorial001 import app
+
+client = TestClient(app)
+
+
+def test_path_operation():
+ response = client.get("/headers/")
+ assert response.status_code == 200
+ assert response.json() == {"message": "Hello World"}
+ assert response.headers["X-Cat-Dog"] == "alone in the world"
+ assert response.headers["Content-Language"] == "en-US"