Skip to content

HEAD requests still return response body #187

@joshvote

Description

@joshvote

A HEAD request to any supported endpoint (eg HEAD /tm) will return the response body as if it were a GET which is slightly against the intended behaviour of HEAD (which should still return headers but no body)

Example test that can expose this for tests/integration/general/test_api.py

@pytest.mark.parametrize(
    "uri", [uri for methods, uri in ALL_ENDPOINTS_WITH_SUPPORTED_METHODS if HTTPMethod.HEAD in methods]
)
@pytest.mark.anyio
async def test_head_has_no_response_body(uri: str, client: AsyncClient, valid_headers: dict):
    response = await client.request(method=HTTPMethod.GET.name, url=uri, headers=valid_headers)
    assert_response_header(response, HTTPStatus.OK, expected_content_type=None)
    assert not read_response_body_string(response)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions