Title: RequestsHTTPTransport does not set headers on session like AIOHTTPTransport does · Issue #613 · graphql-python/gql · GitHub
Open Graph Title: RequestsHTTPTransport does not set headers on session like AIOHTTPTransport does · Issue #613 · graphql-python/gql
X Title: RequestsHTTPTransport does not set headers on session like AIOHTTPTransport does · Issue #613 · graphql-python/gql
Description: Describe the bug When creating a transport = RequestsHTTPTransport with specific headers, transport.session.headers doesn't match what was given to the constructor (and is in transport.headers`) This is at odd with the behaviour of AIOHT...
Open Graph Description: Describe the bug When creating a transport = RequestsHTTPTransport with specific headers, transport.session.headers doesn't match what was given to the constructor (and is in transport.headers`) Th...
X Description: Describe the bug When creating a transport = RequestsHTTPTransport with specific headers, transport.session.headers doesn't match what was given to the constructor (and is in transport.headers`...
Opengraph URL: https://github.com/graphql-python/gql/issues/613
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"RequestsHTTPTransport does not set headers on session like AIOHTTPTransport does","articleBody":"**Describe the bug**\nWhen creating a `transport = RequestsHTTPTransport` with specific headers, `transport.session.headers` doesn't match what was given to the constructor (`and is in `transport.headers`)\n\nThis is at odd with the behaviour of `AIOHTTPTransport`, where we get `transport.session.headers == transport.headers`\n\n**To Reproduce**\nSteps to reproduce the behavior:\n\n```\nimport pytest\n\nfrom gql.transport.requests import RequestsHTTPTransport\nfrom gql.transport.aiohttp import AIOHTTPTransport\n\n@pytest.mark.asyncio\nasync def test_aio_http_transport_session():\n transport = AIOHTTPTransport(\"url\", headers={\"test\": \"header\"})\n await transport.connect()\n assert transport.headers == transport.session.headers\n\n\ndef test_requests_http_transport_session():\n transport = RequestsHTTPTransport(\"url\", headers={\"test\": \"header\"})\n transport.connect()\n assert transport.headers == transport.session.headers\n```\n\n```\n$ uv run pytest -k test_gql -v 130 ↵ ✹ ✭ issue202/rest-client-headers\n================================================= test session starts =================================================\nplatform linux -- Python 3.12.11, pytest-9.1.1, pluggy-1.6.0 -- /home/shtrom/work/simple-github/.venv/bin/python3\ncachedir: .pytest_cache\nrootdir: /home/shtrom/work/simple-github\nconfigfile: pyproject.toml\nplugins: anyio-4.14.2, responses-0.6.0, aioresponses-0.3.0, mock-3.15.1, asyncio-1.4.0\nasyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function\ncollected 34 items / 32 deselected / 2 selected\n\ntest/test_gql.py::test_aio_http_transport_session PASSED [ 50%]\ntest/test_gql.py::test_requests_http_transport_session FAILED [100%]\n\n====================================================== FAILURES =======================================================\n________________________________________ test_requests_http_transport_session _________________________________________\n\n def test_requests_http_transport_session():\n transport = RequestsHTTPTransport(\"url\", headers={\"test\": \"header\"})\n transport.connect()\n> assert transport.headers == transport.session.headers\nE AssertionError: assert {'test': 'header'} == {'User-Agent'... 'keep-alive'}\nE\nE Left contains 1 more item:\nE {'test': 'header'}\nE Right contains 4 more items:\nE {'Accept': '*/*',\nE 'Accept-Encoding': 'gzip, deflate, br, zstd',\nE 'Connection': 'keep-alive',...\nE\nE ...Full output truncated (7 lines hidden), use '-vv' to show\n\ntest/test_gql.py:17: AssertionError\n=============================================== short test summary info ===============================================\nFAILED test/test_gql.py::test_requests_http_transport_session - AssertionError: assert {'test': 'header'} == {'User-Agent'... 'keep-alive'}\n===================================== 1 failed, 1 passed, 32 deselected in 0.10s ======================================\n```\n\n\n**Expected behavior**\n`transport.session.headers == transport.headers` for `RequestHTTPTransport`, same as `AIOHTTPTransport` already does.\n\n**System info (please complete the following information):**\n - OS: Linux x86_64, Ubuntu 26.04\n - Python version: 3.14.4\n - gql version: 4.0\n - graphql-core version: 3.2.11\n","author":{"url":"https://github.com/shtrom","@type":"Person","name":"shtrom"},"datePublished":"2026-08-25T05:13:22Z","url":"https://github.com/graphql-python/gql/issues/613"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:77c7a3bb-4252-78ac-3587-4333fdaccf05 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8E68:1A4D8A:2348C4:2D507D:6AFF9558 |
| html-safe-nonce | fbddd61743661b06052fe5b71ebac6a3482e98204b9d46b296d23e45ebdc4478 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RTY4OjFBNEQ4QToyMzQ4QzQ6MkQ1MDdEOjZBRkY5NTU4IiwidmlzaXRvcl9pZCI6IjE1NjY5NjcyOTczMTMwNTE5OTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 69d5fd736d41772019e8b50e72608f9eebc22f94a7fc1e698e9ceb64ebeb769d |
| hovercard-subject-tag | issue:5242312451 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/graphql-python/gql/613/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9da2c72d2cc6db0d095341be67b83a5ac2f13652cd5c69f583fd4a02f7c56128/graphql-python/gql/issues/613 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9da2c72d2cc6db0d095341be67b83a5ac2f13652cd5c69f583fd4a02f7c56128/graphql-python/gql/issues/613 |
| og:image:alt | Describe the bug When creating a transport = RequestsHTTPTransport with specific headers, transport.session.headers doesn't match what was given to the constructor (and is in transport.headers`) Th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | shtrom |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2c75d045e8c84b51e2ac680086a6dd1eeaf2bc15b82137d22ee5106835d6256c |
| turbo-cache-control | no-preview |
| go-import | github.com/graphql-python/gql git https://github.com/graphql-python/gql.git |
| octolytics-dimension-user_id | 15002022 |
| octolytics-dimension-user_login | graphql-python |
| octolytics-dimension-repository_id | 62077169 |
| octolytics-dimension-repository_nwo | graphql-python/gql |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 62077169 |
| octolytics-dimension-repository_network_root_nwo | graphql-python/gql |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 525b66d22c4f7e6bb8b62934bec198964f7e8b93 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width