Skip to content

bug: using orig_header, you cannot specify large headers #598

Description

@PandaWorker

Describe the bug
When using the orig header and a large header, the client stops writing headers after the large one.

The behavior only happens on http1

If you specify Authorization first in orig_header, then only it will be recorded, if it is the last, then all will be recorded. That is, the problem is clearly with the length of the header.

To Reproduce
Steps to reproduce the behavior:

import asyncio
import random
import string

import wreq


def generate_header_string(length: int) -> str:
    characters = string.ascii_letters + string.digits

    return "".join(random.choice(characters) for _ in range(length))


ORIG_HEADER = wreq.OrigHeaderMap(
    [
        "X-API-Version",
        "Authorization",
        "Host",
        "Connection",
        "Accept-Encoding",
        "User-Agent",
    ]
)

HEADERS = wreq.HeaderMap(
    {
        "X-API-Version": "1",
        "Connection": "Keep-Alive",
        "Accept-Encoding": "gzip",
        "User-Agent": "okhttp/4.12.0",
    }
)


async def main():
    client = wreq.Client(
        emulation=wreq.Emulation(wreq.Profile.OkHttp4_12, headers=False),
        headers=HEADERS,
        # orig_headers=ORIG_HEADER,
        http1_only=True,
        proxies=[],
    )

    big_header_value = generate_header_string(1024)

    resp1 = await client.get(
        "https://get.ja3.zone/",
        headers={"Authorization": "Bearer " + big_header_value},
    )

    resp2 = await client.get(
        "https://get.ja3.zone/",
        headers={"Authorization": "Bearer " + big_header_value},
        orig_headers=ORIG_HEADER,
    )

    data1 = await resp1.text()
    data2 = await resp2.text()

    print(data1, data2)


if __name__ == "__main__":
    asyncio.run(main())

Expected behavior
It should write all headers regardless of length.

Screenshots

Image Image

Additional context
wreq v0.12.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions