Skip to content
PROJECT / 02OPEN SOURCE

capture2tls.

capture2tls turns HTTP/1.1 or HTTP/2 requests copied from Charles Proxy into ready-to-run tls_client or curl_cffi sessions. It preserves the subtle request characteristics that generic generators drop—including header order and protocol selection.

PythonHTTP/1.1HTTP/2tls_clientcurl_cffiCharles Proxy

Architecture

Small boundaries. Explicit behavior.

01

A format detector selects the correct request parser.

02

A normalized request model separates method, URL, headers, cookies, and body.

03

The generator emits readable Python instead of an opaque runtime wrapper.

04

Only the standard library is required to run the converter.

Implementation

The important path, in code.

A representative excerpt showing the project's approach. The complete implementation and history remain available in the public repository.

generated_request.pypython
session = tls_client.Session(    client_identifier="okhttp4_android_13",    random_tls_extension_order=True,)headers = {"Accept": "application/json", "User-Agent": user_agent}session.header_order = list(headers.keys())session.force_http1 = Trueresponse = session.get(url, headers=headers, cookies=cookies)

Capabilities

01

Converts 95%+ of captures without manual correction

02

Parses HTTP/1.1 and HTTP/2 pseudo-headers

03

Separates cookies into an explicit session dictionary

04

Detects JSON and form request bodies

05

Preserves header order and protocol intent