playwright-java
playwright-java copied to clipboard
[Bug]: fulfillImpl does not set body if response specified
Version
1.49.0
Steps to reproduce
kotlin code:
page.route({ it.startsWith(url}) { route ->
val response = route.fetch()
route.fulfill(Route.FulfillOptions().setResponse(response))
}
Expected behavior
I expect that the response is untouched routed through my mocker
Actual behavior
com.microsoft.playwright.impl.RouteImpl#fulfillImpl line 194
APIResponseImpl response = (APIResponseImpl)options.response;
if (response.context.connection == this.connection) {
fetchResponseUid = response.fetchUid();
} else {
byte[] bodyBytes = response.body();
body = Base64.getEncoder().encodeToString(bodyBytes);
isBase64 = true;
length = bodyBytes.length;
}
No idea what response.context.connection == this.connection means but this branch is taken, omitting the body, modifying the request in an unexpected way
Additional context
As a workaround I set .setBodyBytes(response.body()) in addition
Environment
ubuntu 24, chrome, jdk 17