Repository navigation
lkrequest-py v0.2.4
Adds the Chrome 156 and Chrome 157 fingerprints, Trust Anchor Identifiers and a
switch for sending HTTP/1.1 header names in lowercase, and much of what the Rust
library offers and the bindings did not:
every exception now says what failed, pools take their proxies from a function,
names can be looked up by a DNS server of your own or by Python code, log events
can go to Python's logging, and protocol policies, QUIC cooldowns, HSTS
policies, proxy credentials, WebSocket connections and TCP and TLS fingerprints
can be set in full, among the rest listed below. It also moves the bindings to
PyO3 0.30 and refreshes the Rust dependencies, and fixes the proxy pool, which
handed out a key rather than a proxy. Default request headers and request
cookies now go out in the order they were given, as the Rust library sends
them; a copy made by randomize_fingerprint() keeps the options of the client
it copies; and the default fingerprint, Chrome 155, sends its trust-anchor IDs
in Chrome's sorted order instead of shuffling them. Apart from those three, and
unless a new option is used or one Hsts.dynamic() is given to several
sessions, requests go out on the wire exactly as before. Six changes are visible
from Python and worth reading before upgrading: ProxyPool.acquire() now
returns a ProxyLease instead of a string; TimeoutConfig and
ResourceLimits, which nothing accepted, are gone; the exception raised for an
argument of the wrong type no longer names the argument in its message;
Client.session(proxy=...) now raises ValueError for a proxy URL it cannot
parse, where it used to build a session that connected direct; a
ProtocolPolicy whose axes contradict one another raises ValueError when it
is given to a client or a session, rather than on the first request; and the
sessions given one Hsts.dynamic() now share what it learns.
🚀 Features
- Chrome 157 Fingerprint — Added
Client.chrome_157()/BlockingClient.chrome_157(), the"chrome_157"name fortls_profile=/h2_profile=/quic_profile=, andTlsProfile.chrome_157(),TlsProfile.chrome_157_quic(),H2Profile.chrome_157(),QuicProfile.chrome_157(). Captured from Chrome 157.0.8103.39 on Windows, it matches Chrome 156 throughout: the TCP and QUIC ClientHellos differ only in their name, and the H2, QUIC and HTTP/3 profiles are Chrome 156's. The capture confirmed the HTTP/3 SETTINGS and the navigation and favicon priority; timing, loss recovery and resumption carry over from Chrome 156 without being observed again. The default fingerprint stays Chrome 155. - Trust Anchor Identifiers —
ClientandBlockingClienttaketrust_anchor_advertisement=,trust_anchor_recovery=andtrust_anchor_bindings=, for the Rust library's new support of draft-ietf-tls-trust-anchor-ids: the IDs of the roots a client accepts, which the Chrome 152 to 157 profiles send in extension0xca34.trust_anchor_advertisement="trusted"sends the sorted IDs of the roots the client trusts instead of the profile's list.trust_anchor_recovery="once"opens one more connection when a server lists the IDs it can serve and then its certificate chain fails to verify, or it ends the handshake, asking for the first of those IDs the client trusts; at most once per request, with 0-RTT off, and a second failure raises the error of its cause with a message beginningtrust anchor recovery failed.trust_anchor_bindings={id: anchor_identity}gives IDs to roots of your own, and the newlkrequest.trust_anchor_identity(der)computes the identity a binding names a root by; the bundled IDs of the Chrome 157 root store need none. The IDs never change which certificates are trusted. A setting the Rust library rejects raisesValueError: recovery withoutverify, or withproxy_fallback_direct=True,"trusted"or"once"on a profile without the extension or with TLS synthesis, and a binding to a root the client does not load.Response.diagnosticsand thediagnosticsof an exception gainedtrust_anchor, the negotiation of the TLS connection the request opened: the IDs requested and offered, the root that verified the chain and, after a recovery, the first attempt; it isNoneon a pooled connection. Whatever the settings, a TLS failure on a server that listed IDs of its own is no longer retried. - Chrome 156 Fingerprint — Added
Client.chrome_156()/BlockingClient.chrome_156(), the"chrome_156"name fortls_profile=/h2_profile=/quic_profile=, andTlsProfile.chrome_156(),TlsProfile.chrome_156_quic(),H2Profile.chrome_156(),QuicProfile.chrome_156(). Captured from Chrome 156.0.8078.48 on Windows, it matches Chrome 155 throughout: the TCP and QUIC ClientHellos differ only in their name, and the H2, QUIC and HTTP/3 profiles are Chrome 155's. The capture confirmed the HTTP/3 SETTINGS and the navigation and favicon priority updates; timing, loss recovery and resumption carry over from Chrome 155 without being observed again. The default fingerprint stays Chrome 155. - Lowercase HTTP/1.1 Header Names — Added
Client(http1_title_case_headers=...)on both clients, and a read-onlyhttp1_title_case_headersproperty. HTTP/1.1 header names go out in Title-Case (Content-Type) by default, as before;Falsesends them in lowercase (content-type), including generated headers such ascontent-length, except forHost, which keeps its capitalH. It applies to ordinary and streamed requests, preconnected connections and WebSocket handshakes, and leaves header values and order alone. Either way, the spelling a header was given in is not kept, and HTTP/2 and HTTP/3 always send lowercase names. Lowercase names alone do not make a request match what any particular browser sends over HTTP/1.1. - What An Exception Knows About The Failure — Every
RequestErrornow carriesphase,retryable,safe_to_replay,status_code,proxy_error_kind,tls_alertanddiagnostics, read from the Rust library's error, where an exception used to carry its message alone: anHttpStatusErrorcould not give its status code, aProxyErrordid not say whether the proxy wanted credentials or could not be reached, and the timings of a failed request were thrown away.phasenames the step of the connection that failed ("tcp_connect","proxy_tunnel","tls_handshake", …);retryablesays whether trying again could succeed, andsafe_to_replaywhether the server cannot have processed the request, so that even a POST can be sent again;proxy_error_kindsays what went wrong with a proxy ("authentication_required","tunnel_refused", …) andtls_alertwhich alert a handshake ended in;diagnosticsholds the timings and transport so far, in the form ofResponse.diagnostics, for a failed request of the HTTP methods andrequest(), and the response's own forerror_for_status(). An attribute that does not apply isNone, orFalsefor the two flags, on an error built by hand as well, and the attributes survive pickling. A retry callable that also takesexception=(or**kwargs) is given the exception itself, orNonewhen a status is being retried; one taking only(attempt, error, status)is called exactly as before. - Proxies From A Function —
ProxyPool,SessionPoolandBlockingSessionPooltake a function in place of the list of proxies. It is called with no arguments for every proxy the pool hands out and returns a URL or aProxyConfig: the way to use a gateway that picks the exit by a session id in the username, with a new id each time. What the function raises comes out of theacquire()that called it, and so does aValueErrorfor a URL that does not parse or aTypeErrorfor anything but a URL or aProxyConfig, where the Rust library would only log it and keep asking, so thatacquire()waited for good. Anasync defis refused withTypeError. Every proxy from a function is a new one, sorotation,bad_proxy_configandhealth_checkdo not apply to them, andmax_proxies/max_sessionsstill cap how many are out at once. The async pools call the function on a worker thread that waits for it;proxy_buffer=nhasnproxies made ahead of time on a thread of their own, where a failure is logged and the function is called again a second later, rather than at once and over and over as the Rust library would.proxy_buffer=with a list raisesValueError. - Blocking
ProxyPool— Addedlkrequest.blocking.ProxyPool(lkrequest.BlockingProxyPool), which takes the same arguments asProxyPool, blocks inacquire()andacquire_fresh(), and hands out the sameProxyLease. bad_proxy_config=Andhealth_check=For Session Pools —SessionPoolandBlockingSessionPoolnow take theBadProxyConfigandHealthCheckConfigthatProxyPoolalready did, so a session pool can cool a failing proxy down after fewer or more failures than the default three, and probe its proxies in the background.- A DNS Server Of Your Own —
Client(dns=...)andBlockingClient(dns=...)now take the address of a DNS server besides the seven resolver names:"ip"for port 53, or"ip:port", an IPv6 address with a port in brackets ("[2606:4700::1111]:53"). It is asked over UDP, and over TCP for an answer too long for UDP. Like the named public resolvers and unlike the system one, it also answers HTTPS records, which is how the client learns a site's ECH configuration and HTTP/3 support from DNS. Anything that is neither a name nor an address still raisesValueError, whose message now mentions the address form. - Python Code As The Resolver —
dns=also takes Python code that looks names up: a functionresolve(host, port)returning a list of addresses, each an IP, which takes the requested port, or"ip:port"; or an object with that method and, optionally,lookup_https(host), returningNoneor the host's HTTPS record as a dict ofalpn,no_default_alpn,target,port,ech_config_list,ipv4_hintsandipv6_hints, from which the client learns a site's HTTP/3 support and ECH configuration as it would from DNS. The code must be synchronous, and anasync defraisesTypeError; it runs on a thread of the runtime's blocking pool, so a slow lookup holds up no other request.dns_timeoutbounds each call andip_familyfilters the answers, as for any resolver. Whatresolveraises becomes the__cause__of the request'sConnectionError, so its traceback shows the line that failed; an answer that is not an address fails the request with a message saying so, and alookup_httpsthat fails is logged and counts as no record. A copy made byrandomize_fingerprint()keeps the resolver. - Log Events In Python's
logging—set_log_level(level, format="logging")hands every event that passeslevelto Python'slogginginstead of writing it to stderr, on the loggerlkrequest.followed by the event's Rust target with::as.(lkrequest.lkrequest.session,lkrequest.lktls.handshake), sologging.getLogger("lkrequest")takes them all. The message carries the event's fields asname=value; a TRACE event, whichlogginghas no level for, has level 5. The events are queued and passed on from a thread of their own, a batch per hold of the GIL, so a request never waits for the GIL to log; a queue that fills up drops events, and none are passed on once the interpreter starts to exit. As with the other formats, only the first call in a process takes effect. - Every Axis Of A Protocol Policy —
ProtocolPolicygainedwith_acquisition(),with_upgrade()andwith_fallback(), the read-onlyacquisition,upgradeandfallback, andvalidate(), alongside the newAcquisitionPolicy(ReuseExistingFirst,EstablishBestAvailable),RacePolicy,UpgradePolicy(Off,ProbeOnly,ProbeAndMigrate,ForceForNewRequests) andFallbackPolicy(AllowFallback,AllowFallbackOnNetworkErrors,NoFallback). Only the four presets andwith_intent()were available before. ARacePolicyraces TCP against QUIC with the timing given: whether each takes part, the delay before each starts, and whether to race only an origin that has advertised HTTP/3; what it leaves out keepsRacePolicy.chrome_like(), which starts QUIC at once and TCP 0.3 s later. A policy whose axes contradict one another now raisesValueErrorwhen it is given to a client or a session, where the Rust library would only refuse it once the first request was sent; given to a single request, it is still refused before anything goes out. - WebSocket Extensions, Pings And URL —
ws_connect()on both session classes takesextensions=, offered in the upgrade'sSec-WebSocket-Extensionsheader in the order given; the header is part of what a browser's handshake looks like. Both connection classes gainedping(data=b""), whose pong comes back throughrecv(),pong(data=b"")for an unsolicited pong, and a read-onlyurl, still there once the connection is closed. A ping or pong of more than 125 bytes, which a peer would fail the connection for, raisesValueErrorbefore anything is sent. The frames are still read and written plain, so only an extension that leaves them alone can be used: once a server acceptspermessage-deflate, the compression Chrome offers, every compressed message it sends fails to be received withRequestError. - TCP Options, Keep-Alive And Two More TCP Presets —
TcpFingerprint(...)takestcp_options=, the SYN's option order as kind numbers — 0 (EOL), 1 (NOP), 2 (MSS), 3 (window scale), 4 (SACK permitted), 8 (timestamps), the second part of JA4T — andkeepalive=,keepalive_idle=andkeepalive_interval=. The option order only describes the target fingerprint, since the OS builds the SYN, and shows into_ja4t(); keep-alive is set on the socket:keepalive=Trueturns it on with the OS's timing, either timing in seconds turns it on with that timing, andkeepalive=Falseturns it off. An unknown option kind, orkeepalive=Falsegiven with a timing, raisesValueError. AddedTcpFingerprint.to_dict(), which reads every setting back under its argument's name, and the presetsTcpFingerprint.none(), which sets nothing, andTcpFingerprint.safari_ios(). - QUIC Cooldowns Of Your Own —
session(broken_quic_policy=...)on both clients also takes aBrokenQuicConfig, for when none of theBrokenQuicPolicypresets fits how long an origin whose QUIC connection failed should stay on TCP. It takesinitial_cooldown, the seconds after the first failure;max_cooldown, which the cooldown grows to overfailure_escalation_thresholdfailures in a row;route_cooldown, for a proxy route that cannot carry QUIC; andmax_entriesandmax_route_entries, how many origins and routes are remembered. What is left out keeps the value ofBrokenQuicPolicy.Strict, the default, and each value reads back under its own name. A duration that is negative, NaN or infinite, aninitial_cooldownabovemax_cooldownand a count of zero raiseValueError, where the Rust library would quietly capinitial_cooldownatmax_cooldownand take a count of zero as one.Strict,ResilientandDisabledare unchanged. - Proxy Credentials Worked Out Per Connection — Added
ProxyConfig.with_custom_auth(identity, authorize), for a proxy credential that has to be fresh, such as a short-lived token.authorize()takes no arguments and returns the value of theProxy-Authorizationheader, or of the headerwith_auth_header()chose, orNoneto send none. It is called on the thread setting each connection up, which waits for it, and more than once for a connection the proxy challenges with a 407. One that raises, or returns something other than a string, is logged as a warning and the connection goes without a credential, so the request fails with the proxy's answer.identityis a stable string, not a secret, that becomes part ofidentity(), so that pools tell two credentials on the same proxy address apart. Likewith_http_auth(), it replaces any credential already set and raisesValueErroron a SOCKS5 proxy; anasync defraisesTypeError. - Check A Proxy Without A Pool — Added
Client.check_proxy(proxy, target_host="www.google.com", target_port=443, timeout=5.0), and the blockingBlockingClient.check_proxy(), which set a tunnel up through a proxy URL orProxyConfig, chains and credentials included, and return the seconds that took: the health check aProxyPoolruns in the background, made once. Nothing is sent through the tunnel. Names are resolved as the client resolves them, sodns=applies. A proxy that refuses the tunnel or cannot be reached raisesProxyError, one that takes longer thantimeoutraisesTimeoutError, and a MASQUE proxy, which carries no TCP, raisesProxyError. - What A
ProxyConfigPoints At — Added the read-onlyProxyConfig.hostandProxyConfig.port, of the proxy the client talks to last — the only one, or a chain's final hop — with the scheme's port when the URL gives none and an IPv6 address in brackets, andProxyConfig.forbids_direct_fallback, true for a route through a MASQUE proxy, which never falls back to a direct connection, even withproxy_fallback_direct. - HSTS Policies Of Your Own — Added
Hsts.custom(should_upgrade, record_sts=None), a policy written in Python.should_upgrade(host)says whether anhttp://URL, a redirect's included, is upgraded tohttps://;record_sts(host, header), if given, is told the value of eachStrict-Transport-Securityheader received over HTTPS from a host that is not an IP address. They run on the thread running the request, which waits for them; one that raises is logged as a warning and the URL is not upgraded, and anasync defraisesTypeError. AddedHsts.should_upgrade(host), which answers as a session would ask the policy — for a dynamic one, after what it has learned. - Requests Straight From A Client —
ClientandBlockingClientgainedget(),post(),put(),delete(),head(),patch()andoptions(), eachsession().get(url, **kwargs)and so on: the request goes out from a session made for the call and dropped after it, as the Rust library'sClient::get()does, and takes what the session's method of the same name takes. No connection or cookie is kept from one call to the next, so for more than one request a session is still the way. H2Profile.validate()— RaisesValueErrorif an HTTP/2 profile breaks a rule a usable fingerprint keeps: the four pseudo-headers once each, no SETTINGS id twice,ENABLE_PUSH0 or 1,INITIAL_WINDOW_SIZEat most 2**31 − 1,MAX_FRAME_SIZEfrom 16384 to 16777215, and awindow_updatethat keeps the connection window at most 2**31 − 1. The message says which. Nothing else checks, as before: a client sends a profile that breaks one, made by hand or read from JSON, as it is.- TLS Secrets To A Function —
Client(keylog=...)andBlockingClient(keylog=...)take a function besides a file path, called with each line of the NSS key log format Wireshark reads, without its newline, several times per handshake. It runs on the thread doing the handshake, which waits for it, so every line of a request's handshake is in by the time the request returns; one that raises is logged as a warning and the handshake goes on. Anasync defraisesTypeError. A file path may now also be anos.PathLike, such as apathlib.Path. - A DER Certificate For The MASQUE Proxy —
MasqueConfig(ca_cert_der=...)trusts one DER certificate for the hop to a MASQUE proxy, asClient(ca_cert_der=...)does for the origin, alongside any fromca_certandca_cert_pem, and counts inca_cert_count. Bytes that are not a usable certificate raiseValueErrorwhen the config is built, where the Rust library would only refuse them when the first tunnel is set up. - What A Build Offers — Added
lkrequest.features(), which says which optional features this build has, as a dict ofquic-h3,masque,doh,telemetryandsynthetic-fpto booleans, so that a build from source can be told apart without tryinghasattr(lkrequest, "QuicProfile"); the wheels on PyPI have them all. Addedlkrequest.list_presets(), the browser presets in a stable order, each a dict ofname,browserandhttp3, whether the preset's client speaks HTTP/3 in this build; a name is whatClient.<name>(),tls_profile=andh2_profile=take. - What A Client Was Built With —
ClientandBlockingClientgained read-onlytls_profile,h2_profile,tcp_fingerprint,default_headers,header_order,h3_header_order,cookie_order,timeouts,resource_limits,protocol_policy,verify,ip_family,h2_fallback_h1,proxy_fallback_direct,max_pending_h2_requestsandech_config: the settings in effect once the client is built, a preset applied and the defaults included, mostly under the name of the argument that sets each.timeoutsandresource_limitsare dicts keyed by those argument names, durations in seconds, and no cap on connections reads asNone.default_headersgives(name, value)pairs in the order they go out, names lowercased. - ECH And The ClientHello Style On A Hand-Built
TlsProfile—TlsProfile(...)takestls_client_hello_style, the TLS stack whose rules the ClientHello follows where no list says them ("generic", the default,"chromium_boringssl","firefox_nss","safari_cfnetwork"or"java_jsse"),ech, the ECH extension to send, andech_outer_extensions, the extensions an inner ClientHello compresses under real ECH. OnlyTlsProfile.from_json()could set them before. The newEchModegives the extension:EchMode.grease(...), with Chrome's HPKE suite unless told otherwise,EchMode.real(ech_config_list)andEchMode.disabled(). An unknown style, and a GREASE payload minimum above its maximum, raiseValueError.
🔧 Changes
- The Sessions Given One
HstsShare What It Learns —Hsts.dynamic()made a new store for every session it was given to, so a host learned from aStrict-Transport-Securityheader in one session was not upgraded in another, even one given the same object. AnHstsobject now holds one policy, shared by every session it is given to, as one browser profile shares what it learns. Code that gives oneHsts.dynamic()to several sessions now has each of them upgrade what any of them learned; to keep them apart, give each session anHsts.dynamic()of its own.Hsts.static_(),Hsts.none()and the seed ofHsts.dynamic()behave as before. TimeoutConfigAndResourceLimitsRemoved — Both classes could be built, and the README showed them beside the client's timeout options, but nothing ever accepted one, so building one changed nothing. They are gone, fromlkrequestandlkrequest.blockingalike. TheClient/BlockingClientarguments they mirrored —dns_timeout=,tcp_connect_timeout=,tls_handshake_timeout=,ttfb_timeout=,total_timeout=,max_response_body_size=,max_connections_per_session=,min_transfer_rate=and the rest — are unchanged, and remain the way to set these limits.- PyO3 0.30 — The bindings now build on PyO3 0.30 (previously 0.23) and pyo3-async-runtimes 0.30, and the Rust dependencies are refreshed. The wheels still use the stable ABI of Python 3.9 and later; building from source now needs Rust 1.89 or later. What this changes in Python:
- Argument errors no longer name the argument in their message.
get(url, timeout="x")used to raiseTypeError: argument 'timeout': must be real number, not strand now raisesTypeError: must be real number, not str. On Python 3.11 and later the argument is named in a note (while processing 'timeout'), which tracebacks print; Python 3.9 and 3.10 have no exception notes, so there the argument is not named at all. The exception types are unchanged, and so are the messages lkrequest raises itself, such astls_profile must be str (preset name) or TlsProfile object. A value of the wrong class is now reported as'str' object is not an instance of 'ProtocolPolicy'rather than'str' object cannot be converted to 'ProtocolPolicy'. - Enum values returned by lkrequest are the class attributes themselves, so
response.version is HttpVersion.H2now holds;==and hashing behave as before. - The async client hands each result to the event loop from tokio's blocking thread pool rather than from the thread that ran the request, so a result arriving while another thread holds the GIL no longer holds up the requests still in flight. Under load the process may show a few dozen more threads; they exit after ten idle seconds.
- Built from source for a free-threaded Python (3.13t, 3.14t), the module still turns the GIL back on when it is imported, as before: it has not been reviewed for running without the GIL.
- Argument errors no longer name the argument in their message.
- Dependencies Without Known Advisories — The wheels now build with rustls 0.23.46 (0.2.3: 0.23.36), rustls-webpki 0.103.16 (0.103.9), webpki-roots 1.0.10 (1.0.6), aws-lc-sys 0.46.0 (0.37.1), Tokio 1.54.1 (1.49.0) and zstd 0.13.4 (0.13.3) with zstd-safe 7.4.0 (7.2.4); the Rust library now requires rustls-webpki, webpki-roots, Tokio and zstd at 0.103.16, 1.0.10, 1.53.3 and 0.13.4 or later. When this was written,
cargo auditfound no advisory against theCargo.lockthe wheels build from, and 23 vulnerabilities against 0.2.3's. One fix shows from Python: certificate verification now rejects a chain through one of emSign's eight distrusted G3 intermediates, whatever root it ends in, and the bundled Mozilla roots no longer include emSign ECC Root CA - G3, so a server whose certificate was issued under them fails verification.
🐞 Fixes
- Chrome 155 Sends Its Trust-Anchor IDs In Chrome's Order — inherited from upstream, and it changes the default fingerprint on the wire.
Client.chrome_155(), the default, shuffled the 28 IDs of itstrust_anchorsextension (0xca34) on every handshake, where Chrome 155 sorts them before sending them. It now sends them in that one fixed, sorted order, over TCP and QUIC alike, and still shuffles the order of the extensions on every handshake;TlsProfile.chrome_155()lists the IDs sorted, withshufflenowFalse. The Chrome 152 to 154 presets keep shuffling the IDs. ProxyPool.acquire()Returns A Lease With A Usable Proxy —acquire()returned the proxy's pool key,ProxyConfig.identity(), which is not a URL: lately a JSON array that leaves the password out. Passed tosession(proxy=...), as it was meant to be, it built a session without a proxy (see the next entry), so the requests went out direct. And because the pool's share was handed back the momentacquire()returned,max_proxiescapped nothing.acquire()now returns aProxyLease, an incompatible change. Itsproxyis theProxyConfigto pass tosession(proxy=...), credentials included, orNonefrom a pool created with an empty list, which used to return"". The lease holds one of the pool'smax_proxiesshares (default 100) untilrelease(), the end of awithorasync withblock, or garbage collection. AddedProxyLease.mark_bad();ProxyPool.acquire_fresh(lease), which records a failure of the lease's proxy, releases the lease and leases another proxy; andProxyPool.max_concurrent.ProxyPool.mark_bad(identity)is unchanged: pass itlease.proxy.identity().- A Session Proxy URL That Does Not Parse Raises Instead Of Connecting Direct —
Client.session(proxy=...)andBlockingClient.session(proxy=...)handed a proxy URL to the Rust library, which logs a URL it cannot parse and builds the session without a proxy. A typo in the scheme, or a pool key such asProxyConfig.identity()returns, therefore sent every request of that session straight from this machine to the target, exposing its address, and nothing was raised. Such a URL now raisesValueError, as it already did inProxyConfig(...), in the proxy lists ofProxyPoolandSessionPool, and in a request's ownproxy=. randomize_fingerprint()Keeps The Rest Of The Client —Client.randomize_fingerprint()andBlockingClient.randomize_fingerprint()built the copy from the TLS, HTTP/2, TCP and QUIC ClientHello profiles alone, so everything else the client was created with fell back to its default: default headers, header and cookie order,http1_title_case_headers, timeouts and limits,verifyand the CA certificates, DNS,ip_family,connect_to, middleware, the QUIC profile and MASQUE. The copy of a browser preset also lost the preset's header-order templates and QUIC profile, so it stopped sending what that browser sends. The copy is now built again from the same options, or the same preset, with only the TLS profile replaced. A CA file named byca_certis read again when the copy is made.- A
PartCan Be Added To A Form —Partcould be built and given a filename and a content type, but nothing accepted it, so it never reached a request. AddedMultipart.part(part). APartsays whattext()andfile()cannot, such as binary data without a filename, and the samePartcan be added to any number of forms. - A
MultipartCan Be Sent More Than Once — a request emptied theMultipartit was given, so the same form sent again went out with no fields at all, only its closing boundary, and nothing was raised. A form now keeps its fields, and each request encodes them afresh with a boundary of its own, as a browser gives each submission of a form; a field added after a request goes out with the next one. head(),options()Andsend_streaming()Take Every Request Option —head()andoptions()did not acceptno_decompress,accept_encoding,priority,h2_priority_weight,preferred_http_versionoridempotency, andsend_streaming()lacked all of them butaccept_encoding, although the README listed them for every method and the Rust library honours them on these requests too. Passing one raisedTypeError; the way around it wasrequest("HEAD", ...)for the first two and there was none for a streamed request.head()andoptions()now take whatget()takes, andsend_streaming()whatrequest()takes, on both session classes.- Default Headers And Request Cookies Keep Their Order —
Client(default_headers=...)and thecookies=/cookie_override=of every request method were copied into unordered maps, so each client sent its default headers, and each request its cookies, in an arbitrary order of its own: clients built from the same defaults did not agree with one another, and the same request did not produce the sameCookieheader twice — orders no browser produces, over HTTP/1.1 and HTTP/2 alike. The Rust library keeps both in the order they are given, and they are now handed on that way. Default headers go out in the order given whereverheader_orderdoes not place them. Request cookies follow the session's own cookies in the order given, overrides last, unlesscookie_orderplaces them. All three parameters also accept a list of(name, value)pairs, asheaders=does. A default header given twice is sent once, with the last value, where it first appeared; a cookie given twice incookies=is sent twice, as the Rust library sends it. on_requestHooks See The Headers In Order — theheadersdict anon_requesthook receives now lists the request's headers in the order they were given, instead of in an arbitrary one.- A Duration Too Large To Hold Raises
ValueError— A number of seconds of 2**64 or more, such astotal_timeout=1e30, a request'stimeout=or aRacePolicydelay, crashed with aPanicException, which derives fromBaseException, soexcept Exceptiondid not catch it. Every option that takes seconds now raisesValueErrorfor it, as for a negative, NaN or infinite value. A retry callable that returns such a delay no longer crashes the request either: as with a negative delay, the request is not retried and fails with its own error. - A
TcpFingerprintShows What It Sets — its repr wasTcpFingerprint()whenever the four values JA4T is made of were not all set, as for a fingerprint that sets nothing, soTcpFingerprint(ttl=128, keepalive=True)looked likeTcpFingerprint.none(); and when they were, it showed the JA4T alone, soTcpFingerprint.chrome_win()and the same JA4T without a TTL looked alike. It now names every setting that is set, the JA4T ones as oneja4t=when all four are:TcpFingerprint(ja4t='64240_2-1-3-1-1-4_1460_8', ttl=128, tcp_nodelay=True).