Normal responses get the request field via create_response(), but mocked responses only get the request field if they're errors (via handle_resp()). This means the second (loaded from mock) response doesn't exactly match the "real" response (in this example, loaded via httptest2, which might be the proper place to "fix" this, I'm definitely open to that discussion).
The is_error(resp) branch in handle_resp() currently sets resp$request <- req. If that were either set outside the if or also set in the final else, mocked responses would have the same request objects as their unmocked cousins, regardless of the mock-loader that's being used.
I got the expected result locally by adding resp$request <- req in that final else, and could PR that easily, but I want to check if you have a preference of how to handle this (if at all).
Normal responses get the
requestfield viacreate_response(), but mocked responses only get therequestfield if they're errors (viahandle_resp()). This means the second (loaded from mock) response doesn't exactly match the "real" response (in this example, loaded via httptest2, which might be the proper place to "fix" this, I'm definitely open to that discussion).The
is_error(resp)branch inhandle_resp()currently setsresp$request <- req. If that were either set outside theifor also set in the finalelse, mocked responses would have the samerequestobjects as their unmocked cousins, regardless of the mock-loader that's being used.I got the expected result locally by adding
resp$request <- reqin that finalelse, and could PR that easily, but I want to check if you have a preference of how to handle this (if at all).