Repository navigation
Conversation
bf128bd to
4d80be1
Compare
e718154 to
7ca2815
Compare
d102580 to
c48c2bb
Compare
7ca2815 to
fdd1bd8
Compare
There was a problem hiding this comment.
LGTM, just a note: IIUC the idea is that we read the body once and then pass it to the functions that need it, right? This is a nice idea 👍 but we need to make sure that the existing proxy logic does not read the body and drains it which I think we are doing in CreateInterceptor. If that ever runs before the session lookup, there's nothing left to read and we silently get no session ID.
| } | ||
| _ = r.Body.Close() | ||
| var payload []byte | ||
| if len(body) > 0 { |
There was a problem hiding this comment.
I might be wrong here, but I think that if the function is called as GuessSessionID(client, r, nil) or a variable that is nil, len(body) will be 1.
We can have just a new function GuessSessionIDFromPayload
There was a problem hiding this comment.
Yup, can confirm: https://go.dev/play/p/9tZeNpi43Qd
8e5c7c5 to
18de0b0
Compare
fdd1bd8 to
037b358
Compare
5f648df to
5810943
Compare
Adds
client.GuessSessionIDFromPayload(client, r, payload)for reverse-proxy callers that already buffered the body. It preserves header precedence and never reads, closes, or replacesr.Body, including with nil or empty payloads.GuessSessionID(client, r)shares the parsing logic, retains read-and-restore behavior when needed, and handles nil bodies safely. Tests cover both paths and body preservation.Generated by Coder Agents on behalf of @pawbana.