libwww-perl / libwww-perl/HTTP-Cookies

[PATCH] split HTTP::Cookies::add_cookie_header into two methods [rt.cpan.org #23980]

Open
#17 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Perl
Stars
4
Forks
19
PR merge metrics
No merged PRs in 30d

Description

Migrated from rt.cpan.org#23980 (status was 'new')

Requestors:

  • chris+rt@chrisdolan.net

Attachments:

From chris+rt@chrisdolan.net on 2006-12-18 17:27:18:

I'm trying to implement cookie testing methods in Test::WWW::Mechanize
and have found myself replicating a bunch of code from
add_cookie_header() in my scan() callback.  I propose that the cookie
matching code be factored out of add_cookie_header() into a separate
method.  The attached patch implements such a refactoring by creating a
new method called cookie_matching() which accepts a $request and returns
an array of cookies.  add_cookie_header() is thus reduced to just the
data munging steps.  I've deliberately left whitespace alone to minimize
the size of the attached patch, but the code should be re-indented if
applied.

I see from
  http://rt.cpan.org/Ticket/Display.html?id=12151
that you prefer not to implement a more detailed cookie inspection API,
and that you believe that web apps should employ functional tests
instead of unit tests with regard to cookies.  So, I understand if you
reject this patch. However, I believe that unit tests on cookies do make
web testing code significantly simpler, and I've made my patch as
unintrusive as possible.

If this patch is acceptable, then I would be willing to document this
new method as well.

Thanks,
  Chris

Contributor guide

No contributing guide indexed for this repository

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 attached cookie.patch and the existing HTTP::Cookies::add_cookie_header method. Review how its cookie-matching logic is used, then compare the proposed cookie_matching() method, which accepts a request and returns cookies. Done means the matching logic is separated without changing header behavior, with the new method documented if the refactoring is accepted.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.