ashrafiucse opened a new pull request, #6756:
URL: https://github.com/apache/jmeter/pull/6756

   ## Description
   Skip cookies that have reached their expiry time when the `HTTP Cookie 
Manager` builds the `Cookie` header for a request.
   
   `HC4CookieHandler#getCookiesForUrl` now filters out expired cookies (via 
`cookie.isExpired(...)`) in addition to the existing domain/path/secure 
matching. Session cookies, which have no expiry date, are unaffected.
   
   ## Motivation and Context
   Fixes #6428
   
   Cookies that were valid when they were received kept being sent after their 
expiry time had passed:
   
   1. Add an `HTTP Cookie Manager` (with "Clear cookies each iteration?" 
unchecked)
   2. Receive a cookie with an `Expires`/`Max-Age` attribute in the past's 
future (e.g. `Set-Cookie: session_id=abc123; Expires=<now + 60s>; Path=/`)
   3. Wait until the expiry time passes
   4. Send another request to the same host → the expired cookie is still sent
   
   **Root cause:** the expiry date is only checked once, when the `Set-Cookie` 
header is parsed (`addCookieFromHeader`). The send path (`getCookiesForUrl`) 
filters cookies with `cookieSpec.match(...)`, which matches on 
domain/path/secure only and never checks `isExpired`, so a cookie that was 
valid at reception time is sent forever.
   
   ## How Has This Been Tested?
   - New regression tests in `TestHC4CookieManager`:
     - `testCookieExpiredAfterReceptionIsNotSent`: receives a valid cookie 
(future expiry), simulates the passing of time by moving the stored cookie's 
expiry into the past, and asserts `getCookieHeaderForURL` returns `null`
     - `testSessionCookieWithoutExpiryIsStillSent`: guards the session-cookie 
case (no expiry date → still sent)
   - Full `:src:protocol:http:test` suite passes (854 tests, 0 failures)
   - `./gradlew classes style` passes
   - Verified the original repro end-to-end against a locally built 
distribution (expired cookie no longer sent)
   
   ## Types of changes
   - Bug fix (non-breaking change which fixes an issue)
   
   ## Checklist:
   - [x] My code follows the [code style][style-guide] of this project.
   - [x] I have updated the documentation accordingly. (release notes entry 
added to `xdocs/changes.xml`)
   
   [style-guide]: https://wiki.apache.org/jmeter/CodeStyleGuidelines


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to