Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

RequestsHTTPTransport does not set headers on session like AIOHTTPTransport does

Abierto Apto para principiantes
#613 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
84/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
api

Línea de trabajo

Comienza con gql.transport.requests.RequestsHTTPTransport y la reproducción en test/test_gql.py, comparando su comportamiento de sesión con gql.transport.aiohttp.AIOHTTPTransport. Ejecuta la prueba específica para el transporte Requests y confirma que los encabezados de la sesión coinciden con los encabezados del constructor, mientras las pruebas de transporte existentes siguen pasando.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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 AIOHTTPTransport, where we get transport.session.headers == transport.headers

To Reproduce
Steps to reproduce the behavior:

import pytest

from gql.transport.requests import RequestsHTTPTransport
from gql.transport.aiohttp import AIOHTTPTransport

@pytest.mark.asyncio
async def test_aio_http_transport_session():
    transport = AIOHTTPTransport("url", headers={"test": "header"})
    await transport.connect()
    assert transport.headers == transport.session.headers


def test_requests_http_transport_session():
    transport = RequestsHTTPTransport("url", headers={"test": "header"})
    transport.connect()
    assert transport.headers == transport.session.headers
$ uv run pytest -k test_gql -v                130 ↵   ✹ ✭ issue202/rest-client-headers
================================================= test session starts =================================================
platform linux -- Python 3.12.11, pytest-9.1.1, pluggy-1.6.0 -- /home/shtrom/work/simple-github/.venv/bin/python3
cachedir: .pytest_cache
rootdir: /home/shtrom/work/simple-github
configfile: pyproject.toml
plugins: anyio-4.14.2, responses-0.6.0, aioresponses-0.3.0, mock-3.15.1, asyncio-1.4.0
asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 34 items / 32 deselected / 2 selected

test/test_gql.py::test_aio_http_transport_session PASSED                                                        [ 50%]
test/test_gql.py::test_requests_http_transport_session FAILED                                                   [100%]

====================================================== FAILURES =======================================================
________________________________________ test_requests_http_transport_session _________________________________________

    def test_requests_http_transport_session():
        transport = RequestsHTTPTransport("url", headers={"test": "header"})
        transport.connect()
>       assert transport.headers == transport.session.headers
E       AssertionError: assert {'test': 'header'} == {'User-Agent'... 'keep-alive'}
E
E         Left contains 1 more item:
E         {'test': 'header'}
E         Right contains 4 more items:
E         {'Accept': '*/*',
E          'Accept-Encoding': 'gzip, deflate, br, zstd',
E          'Connection': 'keep-alive',...
E
E         ...Full output truncated (7 lines hidden), use '-vv' to show

test/test_gql.py:17: AssertionError
=============================================== short test summary info ===============================================
FAILED test/test_gql.py::test_requests_http_transport_session - AssertionError: assert {'test': 'header'} == {'User-Agent'... 'keep-alive'}
===================================== 1 failed, 1 passed, 32 deselected in 0.10s ======================================

Expected behavior
transport.session.headers == transport.headers for RequestHTTPTransport, same as AIOHTTPTransport already does.

System info (please complete the following information):

  • OS: Linux x86_64, Ubuntu 26.04
  • Python version: 3.14.4
  • gql version: 4.0
  • graphql-core version: 3.2.11
Lenguaje dominante
Python
Estrellas
1.7k
Forks
195
Merge medio
14 min
PR fusionados (30 d)
1

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de graphql-python/gql

Todos los issues de graphql-python/gql

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.