fix: preserve cookie CreatedAt and honor H1 close on reuse - #107
Conversation
Replacing a cookie was resetting CreatedAt, which reorders Cookie headers versus Chrome and RFC 6265. shouldKeepAlive now honors Response.Close and Request.Close so closing sockets are not returned to the idle pool. Pooled H1 retries already rewound via GetBody on main; that path now shares a helper plus tests. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@re-jevi is attempting to deploy a commit to the sardanioss' projects Team on Vercel. A member of the Team first needs to authorize it. |
OverviewThis is a small compatibility PR from a fork ( Cookie jar: HTTP/1 keep-alive: HTTP/1 body rewind: current Please do not auto-merge. Review and merge on GitHub if this looks right. |
Summary
CreatedAtso same-pathCookieorder stays Chrome/RFC 6265-like instead of moving every refreshed cookie to the end of the header.shouldKeepAlivenow honorsResponse.CloseandRequest.Close. Some HTTP parsers strip the hop-by-hopConnectionheader, so a closing socket could previously be returned to the idle pool.GetBodyon current main. That path now shares arewindRequestBodyhelper, with tests for replayable and non-replayable bodies.Test plan
go test ./transport -run 'TestHTTP1ShouldKeepAlive|TestRewindRequestBody'passed on this machinego test ./session -run TestCookieJarReplacementPreservesHeaderOrder— test was updated to wait for a distinct Windows clock tick; please re-run in CI / a Go-on-PATH environmentgo test ./session ./transportRisk
Low. Cookie order only changes when a cookie is replaced (now matches browsers). Keep-alive becomes more conservative when Close is set. Rewind helper preserves existing main retry error behavior (non-replayable body still surfaces the original connection error).
Merge
Ready for review. Do not auto-merge — please review and merge on GitHub.
Made with Cursor