{"id":13814971,"url":"https://github.com/adamfisk/LittleProxy","last_synced_at":"2025-05-15T06:33:45.425Z","repository":{"id":1247720,"uuid":"1186228","full_name":"adamfisk/LittleProxy","owner":"adamfisk","description":"High performance HTTP proxy originally written by your friends at Lantern and now maintained by a stellar group of volunteer open source programmers.","archived":false,"fork":false,"pushed_at":"2024-07-08T17:52:04.000Z","size":7397,"stargazers_count":2066,"open_issues_count":111,"forks_count":780,"subscribers_count":149,"default_branch":"master","last_synced_at":"2024-11-18T22:07:14.650Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.getlantern.org","language":"PHP","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/adamfisk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-12-21T03:50:16.000Z","updated_at":"2024-11-18T11:55:00.000Z","dependencies_parsed_at":"2024-05-02T13:49:12.084Z","dependency_job_id":"794107a7-ae09-466a-9548-dc04a4ebe96f","html_url":"https://github.com/adamfisk/LittleProxy","commit_stats":{"total_commits":854,"total_committers":38,"mean_commits":"22.473684210526315","dds":0.6182669789227166,"last_synced_commit":"70edbe1c502d79449fb5ceb9d00cca6a0759d56f"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamfisk%2FLittleProxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamfisk%2FLittleProxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamfisk%2FLittleProxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adamfisk%2FLittleProxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adamfisk","download_url":"https://codeload.github.com/adamfisk/LittleProxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225335177,"owners_count":17458224,"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":"2024-08-04T04:02:48.596Z","updated_at":"2024-11-19T10:30:49.646Z","avatar_url":"https://github.com/adamfisk.png","language":"PHP","readme":"[![Build Status](https://travis-ci.org/adamfisk/LittleProxy.png?branch=master)](https://travis-ci.org/adamfisk/LittleProxy)\n\nLittleProxy is a high performance HTTP proxy written in Java atop Trustin Lee's excellent [Netty](http://netty.io) event-based networking library. It's quite stable, performs well, and is easy to integrate into your projects. \n\nOne option is to clone LittleProxy and run it from the command line. This is as simple as:\n\n```\n$ git clone git://github.com/adamfisk/LittleProxy.git\n$ cd LittleProxy\n$ ./run.bash\n```\n\nYou can embed LittleProxy in your own projects through Maven with the following:\n\n```\n    \u003cdependency\u003e\n        \u003cgroupId\u003eorg.littleshoot\u003c/groupId\u003e\n        \u003cartifactId\u003elittleproxy\u003c/artifactId\u003e\n        \u003cversion\u003e1.1.2\u003c/version\u003e\n    \u003c/dependency\u003e\n```\n\nOnce you've included LittleProxy, you can start the server with the following:\n\n```java\nHttpProxyServer server =\n    DefaultHttpProxyServer.bootstrap()\n        .withPort(8080)\n        .start();\n```\n\nTo intercept and manipulate HTTPS traffic, LittleProxy uses a man-in-the-middle (MITM) manager. LittleProxy's default\nimplementation (`SelfSignedMitmManager`) has a fairly limited feature set. For greater control over certificate impersonation,\nbrowser trust, the TLS handshake, and more, use a the LittleProxy-compatible MITM extension:\n- [LittleProxy-mitm](https://github.com/ganskef/LittleProxy-mitm) - A LittleProxy MITM extension that aims to support every Java platform including Android\n- [mitm](https://github.com/lightbody/browsermob-proxy/tree/master/mitm) - A LittleProxy MITM extension that supports elliptic curve cryptography and custom trust stores\n\nTo filter HTTP traffic, you can add request and response filters using a \n`HttpFiltersSource(Adapter)`, for example:\n\n```java\nHttpProxyServer server =\n    DefaultHttpProxyServer.bootstrap()\n        .withPort(8080)\n        .withFiltersSource(new HttpFiltersSourceAdapter() {\n            public HttpFilters filterRequest(HttpRequest originalRequest, ChannelHandlerContext ctx) {\n                return new HttpFiltersAdapter(originalRequest) {\n                    @Override\n                    public HttpResponse clientToProxyRequest(HttpObject httpObject) {\n                        // TODO: implement your filtering here\n                        return null;\n                    }\n\n                    @Override\n                    public HttpObject serverToProxyResponse(HttpObject httpObject) {\n                        // TODO: implement your filtering here\n                        return httpObject;\n                    }\n                };\n            }\n        })\n        .start();\n```\n\nPlease refer to the Javadoc of `org.littleshoot.proxy.HttpFilters` to see the \nmethods you can use. \n\nTo enable aggregator and inflater you have to return a value greater than 0 in \nyour `HttpFiltersSource#get(Request/Response)BufferSizeInBytes()` methods. This \nprovides to you a `FullHttp(Request/Response)' with the complete content in your \nfilter uncompressed. Otherwise you have to handle the chunks yourself.\n\n```java\n    @Override\n    public int getMaximumResponseBufferSizeInBytes() {\n        return 10 * 1024 * 1024;\n    }\n```\n\nThis size limit applies to every connection. To disable aggregating by URL at \n*.iso or *dmg files for example, you can return in your filters source a filter \nlike this:\n\n```java\nreturn new HttpFiltersAdapter(originalRequest, serverCtx) {\n    @Override\n    public void proxyToServerConnectionSucceeded(ChannelHandlerContext serverCtx) {\n        ChannelPipeline pipeline = serverCtx.pipeline();\n        if (pipeline.get(\"inflater\") != null) {\n            pipeline.remove(\"inflater\");\n        }\n        if (pipeline.get(\"aggregator\") != null) {\n            pipeline.remove(\"aggregator\");\n        }\n        super.proxyToServerConnectionSucceeded(serverCtx);\n    }\n};\n```\nThis enables huge downloads in an application, which regular handles size \nlimited `FullHttpResponse`s to modify its content, HTML for example. \n\nA proxy server like LittleProxy contains always a web server, too. If you get an \nURI without scheme, host and port in `originalRequest` it's a direct request to \nyour proxy. You can return a `HttpFilters` implementation which answers \nresponses with HTML content or redirects in `clientToProxyRequest` like this:\n\n```java\npublic class AnswerRequestFilter extends HttpFiltersAdapter {\n\tprivate final String answer;\n\n\tpublic AnswerRequestFilter(HttpRequest originalRequest, String answer) {\n\t\tsuper(originalRequest, null);\n\t\tthis.answer = answer;\n\t}\n\n\t@Override\n\tpublic HttpResponse clientToProxyRequest(HttpObject httpObject) {\n\t\tByteBuf buffer = Unpooled.wrappedBuffer(answer.getBytes(\"UTF-8\"));\n\t\tHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK, buffer);\n\t\tHttpHeaders.setContentLength(response, buffer.readableBytes());\n\t\tHttpHeaders.setHeader(response, HttpHeaders.Names.CONTENT_TYPE, \"text/html\");\n\t\treturn response;\n\t}\n}\n```\nOn answering a redirect, you should add a Connection: close header, to avoid \nblocking behavior:\n```java\n\t\tHttpHeaders.setHeader(response, Names.CONNECTION, Values.CLOSE);\n```\nWith this trick, you can implement an UI to your application very easy.\n\nIf you want to create additional proxy servers with similar configuration but\nlistening on different ports, you can clone an existing server.  The cloned\nservers will share event loops to reduce resource usage and when one clone is\nstopped, all are stopped.\n\n```java\nexistingServer.clone().withPort(8081).start()\n```\n\nFor examples of configuring logging, see [src/test/resources/log4j.xml](src/test/resources/log4j.xml).\n\nIf you have questions, please visit our Google Group here:\n\nhttps://groups.google.com/forum/#!forum/littleproxy\n\nTo subscribe, send an E-Mail to mailto:LittleProxy+subscribe@googlegroups.com. \nSimply answering, don't clicking the button, bypasses Googles registration \nprocess. You will become a member. \n\nBenchmarking instructions and results can be found [here](performance).\n\nAcknowledgments\n---------------\n\nMany thanks to [The Measurement Factory](http://www.measurement-factory.com/) for the\nuse of [Co-Advisor](http://coad.measurement-factory.com/) for HTTP standards\ncompliance testing. \n","funding_links":[],"categories":["Projects","PHP","PHP (184)","网络编程","项目"],"sub_categories":["Miscellaneous","杂项"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamfisk%2FLittleProxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadamfisk%2FLittleProxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamfisk%2FLittleProxy/lists"}