piercefreeman / grooveproxy

Groove, a crawling and unit test optimized MITM proxy server.
MIT License
17 stars 0 forks source link

Add optional tape contexts #23

Closed piercefreeman closed 2 years ago

piercefreeman commented 2 years ago

Add the ability to isolate tape contexts from one another by providing a header flag alongside the request to the proxy. The proxy should strip out this header before routing forward.

Tape-ID: XX,

Clients can set their own tape ID, since this is only used as a grouping identifier and doesn't actually matter for the functioning of the API. In the libraries we can set this as a generated uuid.

With requests or fetch like direct libraries, this is simple since there's a 1:1 correlation of header information that is passed from the client to the proxy.

In playwright-like libraries, we'll have to modify the header context via a route injection before it reaches the server:

page.route(**/*, async (req) => {
  req.headers = {
    ...req.headers,
    Tape-ID: ID,
  }
)

This inherently means that we are bound by what headers we can append. For these fallback cases, we distribute non-identified tapes across the global cache. Retrieving a specific tape should be a union of the individual tape flag and the global tape - sorted by timestamp.