-
-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
Description
Hello,
I recently started a Maven project using mitmproxy-java. Anytime I try to change the status code of an intercepted call, I get this error: AttributeError: module 'mitmproxy.http' has no attribute 'HTTPResponse'
`List messages = new ArrayList<>();
MitmproxyJava proxy = new MitmproxyJava("/Library/Frameworks/Python.framework/Versions/3.10/bin/mitmdump", (InterceptedMessage m) -> {
messages.add(m);
m.getResponse().setBody("Hi from Test".getBytes(StandardCharsets.UTF_8));
m.getResponse().getHeaders().add(new String[]{"myTestResponseHeader", "myTestResponseHeaderValue"});
m.getResponse().setStatusCode(500);
return m;
});
proxy.start();
Unirest.setProxy(new HttpHost("localhost", 8080));
HttpResponse<String> response = Unirest.get("http://appium.io").asString();
driver.get("http://appium.io");
System.out.println("RESPONSE");
System.out.println(messages.get(0));
TimeUnit.SECONDS.sleep(15);
proxy.stop();
assertThat(response.getBody()).isEqualTo("Hi from Test");
final InterceptedMessage firstMessage = messages.get(0);
assertThat(firstMessage.getRequest().getUrl()).startsWith("http://appium.io/");
assertThat(firstMessage.getRequest().getHeaders()).containsOnlyOnce(new String[]{"myTestHeader", "myTestValue"});
assertThat(firstMessage.getResponse().getHeaders()).containsOnlyOnce(new String[]{"myTestResponseHeader", "myTestResponseHeaderValue"});
System.out.println(firstMessage.getResponse().getStatusCode());
assertThat(firstMessage.getResponse().getStatusCode()).isEqualTo(500);`
I see that the newest version is 2.0.2 and I'm hoping it has the fix. But currently only 2.0.1 is available on Maven to insert into the POM file.
t-o-n-y-p
Metadata
Metadata
Assignees
Labels
No labels