Skip to content
This repository was archived by the owner on Nov 7, 2026. It is now read-only.
This repository was archived by the owner on Nov 7, 2026. It is now read-only.

Maven, MitmProxy version 9: AttributeError: module 'mitmproxy.http' has no attribute 'HTTPResponse' #20

Closed

Description

@bp32891

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.

Activity

  1. t-o-n-y-p commented on May 5, 2023

    @t-o-n-y-p

    Hello, same thing here. Could you devs please push the fix to maven central? Thanks.

  2. shlmvgett commented on May 6, 2023

    @shlmvgett

    Hi
    The same problem is actual for us, could u update version on mvn repo?

  3. bp32891 commented on May 8, 2023

    @bp32891
    Author

    I did find a work around until they make a push. I created my on jar file from this repo and added it to my pom. Then I had to add more libraries but it now works. I no longer get the error message.

  4. Jonahss commented on May 8, 2023

    @Jonahss
    Member

    Sorry about the delay. I'll see about updating in Maven.

  5. valeo28 commented on May 11, 2023

    @valeo28

    Hi! Please uploade it to Maven Central.

  6. Jonahss commented on May 12, 2023

    @Jonahss
    Member

    Hi, I've been busy on my Wyldcard project, but thanks for poking me to update this. I'll see if I can do it on Monday.

  7. jlipps commented on May 12, 2023

    @jlipps
    Member

    that's such a cool project dude!

  8. re-jim commented on May 16, 2023

    @re-jim

    @Jonahss poke again, please update this.

  9. Jonahss commented on May 18, 2023

    @Jonahss
    Member

    I'm finally working on it :D
    My credentials to Maven Central are no longer valid. I'm talking to the active Appium team to get access.

    Thanks for pinging me, sorry for the delay.

  10. t-o-n-y-p commented on Sep 21, 2023

    @t-o-n-y-p

    Hello, how is the progress on this?

  11. Jonahss commented on Sep 21, 2023

    @Jonahss
    Member

    Hello. I think I have everything I need now. Will work on this today and tomorrow. Thanks again for pinging.

  12. Jonahss commented on Sep 21, 2023

    @Jonahss
    Member

    @t-o-n-y-p @re-jim v2.0.2 published to central repository.
    Can you verify the code works as intended?

  13. t-o-n-y-p commented on Sep 27, 2023

    @t-o-n-y-p

    Unfortunately, I no longer have access to the environment to check it, thanks for publishing though :)

  14. Jonahss commented on Sep 27, 2023

    @Jonahss
    Member
  15. halilcifteci commented on Jan 16, 2024

    @halilcifteci

    Hi, after upgrading my project, there was no problem. thanks @Jonahss

  16. Jonahss commented on Jan 18, 2024

    @Jonahss
    Member

    Yay! Okay, can close with confidence :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions