netty / netty/netty

Cleaner API for HTTP headers

Open
#3,322 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
35.1k
Forks
16.3k
Avg merge
1d 5h
Merged PRs (30d)
143

Description

I see the vast number of methods for getting various typed values out of HttpHeaders as dates, numbers, etc. (maybe these are new-ish? I don't remember them from when I was writing Acteur).

I see what you're trying to do here, but it seems clunky. A pattern similar to what you have for ChannelOption<T> would be cleaner and less bug-prone. For example, a Vary header's value type ought to be a list of kinds of headers - and so forth. And having the API make it difficult to use an inappropriate type is a plus.

It happens that I have such an API in Acteur. It wouldn't take many changes to port that to Netty's codebase - I'd just have to remove the dependency on Joda Time. Typical code in Acteur looks like:

add ( Headers.IF_MODIFIED_SINCE, DateTime.now() );
add ( Headers.AGE, Duration.standardDays ( 2 ) );
// and non-standard headers
add( Headers.stringHeader ( "X-foo" ), "foo" );

Here's the package with that API and the base type for Header types and the collection of built-in headers

If you think this would be interesting, let me know.

Contributor guide

Open the contributing guide

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 inspecting Netty's current HttpHeaders API and the existing ChannelOption pattern mentioned in the issue. Compare those with the linked Acteur HeaderValueType and Headers implementations, then clarify the intended typed-header scope, dependency constraints, and acceptance criteria before attempting work.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.