libwww-perl / libwww-perl/HTTP-Message

Please add chaining mutators

Open
#135 2 comments 1 reaction 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

It's a common form to want to return a newly-constructed object with all the values set into it already, by having mutator methods that return the invocant, so you can easily add more. In such a style you could write:

return HTTP::Response->new( 200 )
    ->set_content_type( "text/plain" )
    ->set_content( "Hello, world" );

As it currently stands, the existing mutator methods like ->header, ->content, etc.. do not return the invocant, thus such a style is impossible and one must use a temporary:

my $resp = HTTP::Response->new( 200 );
$resp->content_type( "text/plain" );
$resp->content( "Hello, world" );
return $resp;

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 methods named in the issue, including header, content, set_content_type, and set_content. Check how their current return values are specified or tested, then update the relevant mutators so chaining returns the invocant and verify the example construction style works.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.