libwww-perl / libwww-perl/HTTP-Message

Please add a "fix content length" mutator

Open
#136 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Perl
Stars
32
Forks
63
Avg merge
5h 14m
Merged PRs (30d)
1

Description

99% of the time I create an HTTP::Response I forget to set the Content-Length header, thus stalling the HTTP pipeline. To fix this one simply has to remember to

$resp->content_length( length $resp->content );

Which is reasonable enough if you have the response in a variable. However, #135 wishes to add chaining mutators in order to support fully-constructing a response object in a single expression without needing such a temporary. Without it it becomes hard to fix the content length.

I'd therefore suggest either a special "fix the content length" method, or else the default behaviour of a ->set_content_length method with no additional arguments, to do this.

return HTTP::Response->new( 200 )
    ->set_content( join "\n", @lines )
    ->set_content_length;

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 with the HTTP::Response mutator entry points and read issue #135 for the intended chaining behavior. The work is done when a response can derive its Content-Length from its content through the proposed chained API, with the behavior covered by the project's existing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
perl
Domain
networking
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.