libwww-perl / libwww-perl/HTTP-Message
Please add chaining mutators
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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