Code Monkey home page Code Monkey logo

Comments (7)

joelwurtz avatar joelwurtz commented on July 24, 2024

About public API, here is my 2 cents :

  • It should not mention huffman in public methods (most people don't [want to] care about it)
  • There should be no init method (if required it should be private / lazy, i don't want to care about it, and if many libraries use it i don't know if it's already initialized or not)
  • IMO it should have only 2 methods (static or simple functions) :
[public static] function encodeHeaders(array $headers): string;

[public static] function decodeHeaders(string $binary): array;

But not sure on how works hpack precisely and if it's possible to have this api

from hpack.

kelunik avatar kelunik commented on July 24, 2024

@joelwurtz You don't have to call init(), it's automatically called at the end of the file and lazy, because it's only executed when the file is required.

Two methods aren't possible, because the dictionary can grow (but I think currently does not).

from hpack.

trowski avatar trowski commented on July 24, 2024
I'm not entirely clear on why there are public `huffmanEncode` and `huffmanDecode` methods. Those likely should just be private. The public API only really needs to consist of `encode`, `decode`, and `tableResize`. `encode` should be an instance method, since it should be using a dynamic table for encoding (not implemented yet, but making it an instance method will allow that at any time).

from hpack.

kelunik avatar kelunik commented on July 24, 2024

Shouldn't it be resizeTable()?

I guess the rest should be private and the initialization maybe done via (function () { static::init(); })->bindTo(null, HPack::class)();

from hpack.

bwoebi avatar bwoebi commented on July 24, 2024

The huffmanEncode/huffmanDecode functions are specific if you want to roll your own HPack (e.g. with a dynamic table). You do not need them for header encoding and decoding. That's what HPack::encode() and HPack::decode() are for.

They are more like helper functions, which I decided to make public - if one needs them. Ultimately they are specified by the RFC, have well-defined ins and outs.

from hpack.

kelunik avatar kelunik commented on July 24, 2024

I think the public API is fine now, but the encoding needs tests as it seems, decoding has tests.

from hpack.

kelunik avatar kelunik commented on July 24, 2024

The README can be added later. ;-P

from hpack.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.