Consider further adjustments to the headers structure.
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 20/100
- Issue-Typ
- Refactoring
- Klarheit
- Muss geklärt werden
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- python
- Bereich
- api, networking
Rechercherichtung
Beginne mit der Überprüfung der Funktionen send_headers und push_stream sowie der in der Issue genannten Ereignisse RequestReceived, ResponseReceived, InformationalResponseReceived, TrailersReceived und PushedStreamReceived. Vergleiche die drei vorgeschlagenen Header-Darstellungen und ihre Auswirkungen auf die Abwärtskompatibilität; abgeschlossen bedeutet, dass die Community eine API-Überarbeitung ausgewählt und spezifiziert hat.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
@rbtcollins and I have had a really interesting discussion on IRC about #194, and in particular about the API decision that was made in that issue. For those who don't remember, the end result was that we have a tuple-like datastructure (actually a tuple-subclass) that has a flag on it to indicate whether a header field should be indexable at the HPACK layer.
@rbtcollins has pointed out that this API is a bit prone to mis-use. In particular, the HeaderTuple quacks very much like a tuple, right the way down to its equality comparison (NeverIndexedHeaderTuple('name', 'value') == ('name', 'value')). This runs the risk of users who incautiously use this API failing to notice the distinction, and worse, failing to preserve it when working with the header fields.
Now, this is mostly a concern for intermediaries. hyper-h2 does some automatic never-indexing for some fields, and in most cases for clients/servers that will be enough (and we'll likely add a new API for hooking into that shortly). However, it's vital that intermediaries preserve the relevant semantics of these header fields through their manipulations, and that is something that they could easily get wrong if they're insufficiently cautious.
So we should consider whether or not we can replace this with a better API. The "headers as list-of-tuples" API is a really good one, partly because it preserves all the relevant data about the header fields, but also because it makes header fields immutable data structures, which solves a whole lot of pain points (and indeed we should ask ourselves whether hyper-h2 should convert the header iterable to a tuple, instead of a list, when emitting it to the user on events). We want to preserve this as much as possible.
Three alternative ideas have been proposed, the first two of which of which are backward-incompatible with the current headers representation and would require a SemVer Major version bump.
- Some kind of composite data structure. Essentially, we'd change headers from a
HeaderTupleto a dictionary: a bit like{'indexable': True, 'field': field}, wherefieldis aHeaderTupleortuple. - Wrap the header tuple, rather than subclass. Essentially, have
HeaderField = namedtuple('HeaderField', ['indexable', 'field']). - Adjust the equality logic of
HeaderTupleto prevent theNeverIndexedHeaderFieldfrom comparing equal to a regular tuple.
My thoughts:
- If we believe this is a problem that requires an API change, I don't think (3) goes far enough. If this information is important enough to make users think about it, (3) doesn't do that: in particular, it makes it all-to-easy for users to accidentally throw this information away (by unpacking and repacking the tuple). It's basically only marginally better than the current state, and doesn't save users from their most likely mistake.
- (1) loses some of our immutability wins: dicts are mutable, and that's pretty sad. Additionally, there's no dot-access. On the other hand, it's very easily extensible.
- Of the set, (2) is probably my favourite.
- Regardless of what we do, revising this API is a big change: we'll affect two functions (
send_headers,push_stream) and five events (RequestReceived, ResponseReceived, InformationalResponseReceived, TrailersReceived, PushedStreamReceived), including two events that are in the basic set of events that all implementations will want to handle. Essentially, this means that if we do (1) or (2) we'll definitely break every single implementation that currently exists.
At this point I'd like to solicit some feedback from the community. Is this a problem that's big enough to justify a fairly substantial API revision? If so, do you have a preferred API design? If not, why not?
I'm going to CC: @mhils @Kriechi @hawkowl @sigmavirus24 and @jimcarreer as the community reps on this. Feel free to also CC anyone else who might have a useful opinion here.
- Vorherrschende Sprache
- Python
- Sterne
- 1k
- Forks
- 199
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus python-hyper/h2
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 45/100
python-hyper/h2#1330 ·
-
content-length is not policed when a stream ends with a trailers sectionEvtl. vergeben @feiiiiii5 hat das vor 35 Tagen übernommen. Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 76/100
python-hyper/h2#1328 ·
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
python-hyper/h2#1312 ·
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
python-hyper/h2#1280 · 2 Kommentare ·
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
python-hyper/h2#1239 · 3 Reaktionen ·
Alle Issues in python-hyper/h2
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
pydantic/pydantic-ai#12091 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 1 Tag
-
Enhance blog readabilityOffenCSS enhancement good first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
pychess/pychess-variants#2448 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bump locked PyTensor so Apple clang 21 does not pass -ld64Evtl. vergeben @drbenvincent hat das heute übernommen. Offenbug dev ops
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 2 Tagen
-
ai_p2 bug comp-datalake
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
ClickHouse/ClickHouse#128306 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag