Skip to content

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

@Vizonex

Description

@Vizonex

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions