{"id":28564043,"url":"https://github.com/appium/mitmproxy-java","last_synced_at":"2025-06-10T13:09:24.936Z","repository":{"id":49330952,"uuid":"181068418","full_name":"appium/mitmproxy-java","owner":"appium","description":"A bridge between Python's mitmproxy and Java programs. Built on top of mitmproxy-node","archived":false,"fork":false,"pushed_at":"2023-09-22T22:51:38.000Z","size":110,"stargazers_count":66,"open_issues_count":11,"forks_count":21,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-04-19T10:56:26.402Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/appium.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-12T19:05:25.000Z","updated_at":"2025-03-04T12:38:05.000Z","dependencies_parsed_at":"2022-09-23T20:40:51.023Z","dependency_job_id":null,"html_url":"https://github.com/appium/mitmproxy-java","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appium%2Fmitmproxy-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appium%2Fmitmproxy-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appium%2Fmitmproxy-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appium%2Fmitmproxy-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appium","download_url":"https://codeload.github.com/appium/mitmproxy-java/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appium%2Fmitmproxy-java/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259080989,"owners_count":22802404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-10T13:09:23.999Z","updated_at":"2025-06-10T13:09:24.918Z","avatar_url":"https://github.com/appium.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"Java rendition of [node-mitmproxy](https://github.com/jvilk/mitmproxy-node)\n\nMake sure to read the prerequisites section below.\n\nDetailed information included in the [AppiumPro article which introduces this library](https://appiumpro.com/editions/65).\n\n## Why?\n\n`mitmproxy` is great for capturing network traffic, but has no easy interface for Java users.\nThe software testing community, specifically Appium mobile testers, want to be able to capture network requests made by devices during their Java tests.\n\nThis library will run `mitmproxy` in the background as a separate process, and allow you to pass in a lambda function which gets called on every network request captured by `mitmproxy`. This allows you to check the captured requests within you Java code without having to stop the proxy or end capture.\n\nSee @jonahss's Appium Pro posts on this topic:\n- https://appiumpro.com/editions/62\n- https://appiumpro.com/editions/63\n- https://appiumpro.com/editions/65\n\n## What can I use this for?\n\nFor transparently rewriting HTTP/HTTPS responses. The mitmproxy plugin lets every HTTP request go through to the server uninhibited, and then passes it to Java via a WebSocket for rewriting.\n\n## How does it work?\n\n`mitmproxy-java` starts a Websocket server and a Python plugin for `mitmproxy` connects to it and sends requests over. The two communicate via binary messages to reduce marshaling-related overhead.\n\n## Pre-requisites\n\n* [`mitmproxy` V9](https://mitmproxy.org/) must be installed and runnable from the terminal. The install method cannot be a prebuilt binary or homebrew, since those packages are missing the Python websockets module. Install via `pip` or from source.\n* Python 3.6 and above, since we use the new async/await syntax in the mitmproxy plugin\n* `pip3 install websockets`\n\nMaven:\n```\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.appium\u003c/groupId\u003e\n  \u003cartifactId\u003emitmproxy-java\u003c/artifactId\u003e\n  \u003cversion\u003e2.0.2\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nGradle:\n```\ntestCompile group: 'io.appium', name: 'mitmproxy-java', version: '2.0.2'\n```\n\n## Usage\n\n```java\nList\u003cInterceptedMessage\u003e messages = new ArrayList\u003cInterceptedMessage\u003e();\n\n//optional, default port is 8080\nint mitmproxyPort = 8090;\n\n//optional, you can pass null if no extra params\nList\u003cString\u003e extraMitmproxyParams = Arrays.asList(\"param1\", \"value1\", \"param2\", \"value2\");\n\n// remember to set local OS proxy settings in the Network Preferences\nproxy = new MitmproxyJava(\"/usr/local/bin/mitmdump\", (InterceptedMessage m) -\u003e {\n    System.out.println(\"intercepted request for \" + m.getRequest().getUrl());\n    messages.add(m);\n    return m;\n}, mitmproxyPort, extraMitmproxyParams);\n\nproxy.start();\n\n// do stuff\n\nproxy.stop();\n```\n\nIf the above code doesn't work, and you are getting \n`Error=2, No such file or directory` please re-check your mitmdump path in new MitmproxyJava initialization.\nYou can get mitmdump path using below command:\n```shell\nwhereis mitmdump\n```\n\nSee AppiumPro article for more guidelines: https://appiumpro.com/editions/65\nExample can be found here: https://github.com/cloudgrey-io/appiumpro/blob/master/java/src/test/java/Edition065_Capture_Network_Requests.java\n\n## Your Java code is bad and you should feel bad\n\nI'm no Java expert! You may see some bad patterns, like my terrible disregard for exception handling. Let's make it better. File your issues and land some PRs! I wrote this in just a couple days for our weekly newsletter.\n\n## Your Python plugin is bad and you should feel bad\n\nSee [node-mitmproxy](https://github.com/jvilk/mitmproxy-node/blob/master/README.md#your-python-plugin-is-bad-and-you-should-feel-bad). Pull requests welcome!\n\n## Develop\n\nUpload to Central Repository with command `./gradlew uploadArchives`\nSet username and password in `build.gradle` file","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappium%2Fmitmproxy-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappium%2Fmitmproxy-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappium%2Fmitmproxy-java/lists"}