diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..5cd3e51
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,76 @@
+# Contributing to Starlette
+
+The Starlette team happily welcomes contributions. This document will help you get ready to contribute to Starlette!
+
+> **NOTE**: before writing any code, please first [open an issue] and discuss your ideas with the maintainers.
+
+## Setting up the repository
+
+1. Fork the repo.
+2. Clone your fork on your local computer: `git clone https://github.com/<username>/starlette.git`.
+3. Install Starlette locally and run the tests (see next sections).
+4. Create a branch for your work, e.g. `git checkout -b fix-some-bug`.
+5. Remember to include tests and documentation updates if applicable.
+6. Once ready, push to your remote: `git push origin fix-some-bug`.
+ 7. [Open a PR] on the main repo.
+
+## Install
+
+- Make sure you are using a compatible Python version, as specified in our README.
+- Create a virtual environment and install project dependencies:
+
+```bash
+python -m venv venv
+source venv/bin/activate
+pip install -r requirements.txt
+```
+
+- Install an editable version of the project: `pip install -e .` (see [Editable Installs] in the `pip` docs).
+
+## Running the tests
+
+The tests are written using [pytest] and located in the `tests/` directory.
+
+**Note**: tests should be run before making any changes to the code in order to make sure that everything is running as expected.
+
+We provide a stand-alone **test script** to run tests in a reliable manner. Run it with:
+
+```bash
+./scripts/test
+```
+
+By default, tests involving a database are excluded. To include them, set the `STARLETTE_TEST_DATABASE` environment variable to the URL of a PostgreSQL database, e.g.:
+
+```bash
+export STARLETTE_TEST_DATABASE="postgresql://localhost/starlette"
+```
+
+## Linting
+
+We use [Black] as a code formatter. To run it along with a few other linting tools, we provide a stand-alone linting script:
+
+```bash
+./scripts/lint
+```
+
+If linting has anything to say about the code, it will format it in-place.
+
+To keep the code style consistent, you should apply linting before committing.
+
+## Documentation
+
+The documentation is built with [MkDocs], a Markdown-based documentation site generator.
+
+To run the docs site in hot-reload mode (useful when editing the docs), run `$ mkdocs serve` in the project root directory.
+
+For your information, the docs site configuration is located in the `mkdocs.yml` file.
+
+Please refer to the [MkDocs docs][MkDocs] for more usage information, including how to add new pages.
+
+[open an issue]: https://github.com/encode/starlette/issues/new
+[Open a PR]: https://github.com/encode/starlette/compare
+[pytest]: https://docs.pytest.org
+[pytest-cov]: https://github.com/pytest-dev/pytest-cov
+[Black]: https://www.google.com/search?client=safari&rls=en&q=github+black&ie=UTF-8&oe=UTF-8
+[MkDocs]: https://www.mkdocs.org
+[Editable Installs]: https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs
diff --git a/starlette/responses.py b/starlette/responses.py
index 542e800..3b8d275 100644
--- a/starlette/responses.py
+++ b/starlette/responses.py
@@ -63,8 +63,8 @@ class Response:
                 for k, v in headers.items()
             ]
             keys = [h[0] for h in raw_headers]
-            populate_content_length = b"content-length" in keys
-            populate_content_type = b"content-type" in keys
+            populate_content_length = b"content-length" not in keys
+            populate_content_type = b"content-type" not in keys
 
         body = getattr(self, "body", b"")
         if body and populate_content_length:

Contributing guidelines
Hi!

While figuring out a potential solution for #289, I had to setup the repo and install Starlette locally.

Although the process is rather straight-forward, I think it would be good practice to have contribution guidelines to make things clear and facilitate contributor onboarding.

I already went ahead and committed a [draft](https://github.com/encode/starlette/commit/df8805aa1ba26e46d90673a53e7029bc113380b7) to my fork based on the guidelines I wrote for Bocadillo. If it looks fine, I'd be happy to open a PR. :+1:
diff --git a/tests/test_responses.py b/tests/test_responses.py
index 0b79051..d4bafaf 100644
--- a/tests/test_responses.py
+++ b/tests/test_responses.py
@@ -275,3 +275,15 @@ def test_template_response():
 def test_template_response_requires_request():
     with pytest.raises(ValueError):
         TemplateResponse(None, {})
+
+
+def test_populate_headers():
+    def app(scope):
+        headers = {}
+        return Response(content="hi", headers=headers, media_type="text/html")
+
+    client = TestClient(app)
+    response = client.get("/")
+    assert response.text == "hi"
+    assert response.headers["content-length"] == "2"
+    assert response.headers["content-type"] == "text/html; charset=utf-8"

pip install -e .[full]
parse_log_pytest
requirements.txt
apt-get update apt-get install -y postgresql postgresql-client
3.7
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
aiofiles==23.2.1
asyncpg==0.28.0
Babel==2.14.0
black==23.3.0
certifi @ file:///croot/certifi_1671487769961/work/certifi
charset-normalizer==3.4.1
click==8.1.8
codecov==2.1.13
colorama==0.4.6
coverage==7.2.7
exceptiongroup==1.2.2
ghp-import==2.1.0
graphene==3.4.3
graphql-core==3.2.6
graphql-relay==3.2.0
greenlet==3.1.1
idna==3.10
importlib-metadata==6.7.0
iniconfig==2.0.0
isort==5.11.5
itsdangerous==2.1.2
Jinja2==3.1.6
Markdown==3.4.4
MarkupSafe==2.1.5
mergedeep==1.3.4
mkdocs==1.5.3
mkdocs-material==9.2.7
mkdocs-material-extensions==1.2
mypy==1.4.1
mypy-extensions==1.0.0
packaging==24.0
paginate==0.5.7
pathspec==0.11.2
platformdirs==4.0.0
pluggy==1.2.0
psycopg2-binary==2.9.9
Pygments==2.17.2
pymdown-extensions==10.2.1
pytest==7.4.4
pytest-cov==4.1.0
python-dateutil==2.9.0.post0
python-multipart==0.0.8
pytz==2025.2
PyYAML==6.0.1
pyyaml_env_tag==0.1
regex==2022.10.31
requests==2.31.0
six==1.17.0
SQLAlchemy==2.0.40
-e git+https://github.com/encode/starlette.git@9d20c9f6d6a8e659460e6781745d8a286dc42442#egg=starlette
tomli==2.0.1
typed-ast==1.5.5
typing_extensions==4.7.1
ujson==5.7.0
urllib3==2.0.7
watchdog==3.0.0
zipp==3.15.0

name: starlette
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=22.3.1=py37h06a4308_0
  - python=3.7.16=h7a1cb2a_0
  - readline=8.2=h5eee18b_0
  - setuptools=65.6.3=py37h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - aiofiles==23.2.1
      - asyncpg==0.28.0
      - babel==2.14.0
      - black==23.3.0
      - charset-normalizer==3.4.1
      - click==8.1.8
      - codecov==2.1.13
      - colorama==0.4.6
      - coverage==7.2.7
      - exceptiongroup==1.2.2
      - ghp-import==2.1.0
      - graphene==3.4.3
      - graphql-core==3.2.6
      - graphql-relay==3.2.0
      - greenlet==3.1.1
      - idna==3.10
      - importlib-metadata==6.7.0
      - iniconfig==2.0.0
      - isort==5.11.5
      - itsdangerous==2.1.2
      - jinja2==3.1.6
      - markdown==3.4.4
      - markupsafe==2.1.5
      - mergedeep==1.3.4
      - mkdocs==1.5.3
      - mkdocs-material==9.2.7
      - mkdocs-material-extensions==1.2
      - mypy==1.4.1
      - mypy-extensions==1.0.0
      - packaging==24.0
      - paginate==0.5.7
      - pathspec==0.11.2
      - platformdirs==4.0.0
      - pluggy==1.2.0
      - psycopg2-binary==2.9.9
      - pygments==2.17.2
      - pymdown-extensions==10.2.1
      - pytest==7.4.4
      - pytest-cov==4.1.0
      - python-dateutil==2.9.0.post0
      - python-multipart==0.0.8
      - pytz==2025.2
      - pyyaml==6.0.1
      - pyyaml-env-tag==0.1
      - regex==2022.10.31
      - requests==2.31.0
      - six==1.17.0
      - sqlalchemy==2.0.40
      - tomli==2.0.1
      - typed-ast==1.5.5
      - typing-extensions==4.7.1
      - ujson==5.7.0
      - urllib3==2.0.7
      - watchdog==3.0.0
      - zipp==3.15.0
prefix: /opt/conda/envs/starlette

tests/test_responses.py::test_populate_headers
tests/test_responses.py::test_text_response tests/test_responses.py::test_bytes_response tests/test_responses.py::test_ujson_response tests/test_responses.py::test_redirect_response tests/test_responses.py::test_streaming_response tests/test_responses.py::test_response_headers tests/test_responses.py::test_response_phrase tests/test_responses.py::test_file_response tests/test_responses.py::test_file_response_with_directory_raises_error tests/test_responses.py::test_file_response_with_missing_file_raises_error tests/test_responses.py::test_set_cookie tests/test_responses.py::test_delete_cookie tests/test_responses.py::test_template_response tests/test_responses.py::test_template_response_requires_request
starlette/responses.py CONTRIBUTING.md
starlette/responses.py CONTRIBUTING.md