python-hyper / python-hyper/h2

Wanted to extend hpack encoders or allow different Encoder and Decoders to be used.

Open
#1,312 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1k
Forks
187
PR merge metrics
No merged PRs in 30d

Description

I have a library coming out which I made as a drop in replacement for python hpack called cyhpack and I wanted to try developing a better solution for injecting my own Decoder and Encoder which runs ls-hpack under the hood. As of currently, here is my workaround but I was wondering if a better implementation could be implemented such as a factory attribute or an Abstract class could be made to accommodate my version and the pure python one as well?

from __future__ import annotations

from h2.config import H2Configuration
from h2.connection import H2Connection as _H2Connection

from .hpack import Decoder, Encoder


class H2Connection(_H2Connection):
    """
    Contains an overridable version of H2Connection that drops
    python hpack in exchange for cyhpack for faster performance
    and speed.
    """

    def __init__(self, config: H2Configuration | None = None):
        super().__init__(config)
        self.encoder = Encoder()
        self.decoder = Decoder()

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading h2.connection.H2Connection and H2Configuration, then compare how the current encoder and decoder are initialized with the subclass workaround shown in the issue. The work is done when callers can use alternate Encoder and Decoder implementations without maintaining a custom H2Connection subclass, with coverage for the configuration path.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.