{"id":33179341,"url":"https://github.com/libetl/curl","last_synced_at":"2026-01-14T03:37:36.479Z","repository":{"id":39979459,"uuid":"63108176","full_name":"libetl/curl","owner":"libetl","description":"cURL command in full java. Any argument/option you need raise an issue here.","archived":false,"fork":false,"pushed_at":"2025-12-05T13:16:40.000Z","size":670,"stargazers_count":124,"open_issues_count":17,"forks_count":32,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-12-07T19:29:54.162Z","etag":null,"topics":["curl","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/libetl.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2016-07-11T22:59:53.000Z","updated_at":"2025-12-05T13:16:42.000Z","dependencies_parsed_at":"2024-07-30T16:44:06.003Z","dependency_job_id":"06aeda72-2d08-43fe-bb4d-c59e69de2f08","html_url":"https://github.com/libetl/curl","commit_stats":null,"previous_names":[],"tags_count":46,"template":false,"template_full_name":null,"purl":"pkg:github/libetl/curl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libetl%2Fcurl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libetl%2Fcurl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libetl%2Fcurl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libetl%2Fcurl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/libetl","download_url":"https://codeload.github.com/libetl/curl/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/libetl%2Fcurl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408850,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["curl","java"],"created_at":"2025-11-16T03:00:36.829Z","updated_at":"2026-01-14T03:37:36.471Z","avatar_url":"https://github.com/libetl.png","language":"Java","readme":"# curl [![License: Unlicense](https://img.shields.io/badge/license-Unlicense-blue.svg)](http://unlicense.org/)\ncurl command in java (using Apache libs : HttpClient 5 and commons-cli)\n\nSetup with maven\n\n`\u003cdependency\u003e`\n\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;`\u003cgroupId\u003eorg.toile-libre.libe\u003c/groupId\u003e`\n\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;`\u003cartifactId\u003ecurl\u003c/artifactId\u003e`\n\n\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;`\u003cversion\u003e`![LATEST](https://img.shields.io/maven-central/v/org.toile-libre.libe/curl?label=%20\u0026style=for-the-badge)`\u003c/version\u003e`\n\n`\u003c/dependency\u003e`\n\nUsage\n```java\n    org.apache.hc.core5.http.ClassicHttpResponse org.toilelibre.libe.curl.Curl.curl (String curlParams);\n    String org.toilelibre.libe.curl.Curl.$ (String curlCommand); //Returns responseBody\n```\n\nYou can import static these methods :\n```java\n    import static org.toilelibre.libe.curl.Curl.curl;\n    import static org.toilelibre.libe.curl.Curl.$;\n```\n\nExamples :\n```java\n    $(\"curl https://localhost:8443/public/\");\n    $(\"curl -k https://localhost:8443/public/\");\n    curl(\"-k https://localhost:8443/public/\");\n    curl(\"-k --cert src/test/resources/client.p12:password https://localhost:8443/public/\");\n    curl(\"-k https://localhost:8443/public/redirection\");\n    curl(\"-k https://localhost:8443/public/unauthorized\");\n    curl(\"-k -L https://localhost:8443/public/redirection\");\n    curl(\"-k -H'Host: localhost' -H'Authorization: 00000000-0000-0000-0000-000000000000' https://localhost:8443/public/v1/coverage/sncf/journeys?from=admin:7444extern\");\n    curl(\"-k -X GET -H 'User-Agent: curl/7.49.1' -H 'Accept: */*' -H 'Host: localhost'  'https://localhost:8443/public/curlCommand1?param1=value1\u0026param2=value2'\");\n    curl(\"-k -X GET -H 'User-Agent: curl/7.49.1' -H 'Accept: */*' -H 'Host: localhost' -u foo:bar 'https://localhost:8443/private/login'\");\n    curl(\"-L -k -X GET -H 'User-Agent: curl/7.49.1' -H 'Accept: */*' -H 'Host: localhost' -u user:password 'https://localhost:8443/private/login'\");\n    curl(\"-k -X POST 'https://localhost:8443/public/json' -d '{\\\"var1\\\":\\\"val1\\\",\\\"var2\\\":\\\"val2\\\"}'\");\n    new Curl(with().simpleArgsParsing().build()).curl_(\"-k -G \\\"http://localhost:8200/v1/secret/booking-service/auth\\\"\")\n```\n\nIt also works with a builder\n\n```java\n    HttpResponse response = curl().k().xUpperCase(\"POST\").d(\"{\\\"var1\\\":\\\"val1\\\",\\\"var2\\\":\\\"val2\\\"}\").run(\"https://localhost:8443/public/json\");\n```\n\nHow to get Google Homepage with this lib :\n```java\n    public String getGoogleHomepage (){\n        //-L is passed to follow the redirects\n        return curl ().lUpperCase ().$ (\"https://www.google.com/\");\n    }\n```\n\nYou can also specify five additional curl options using jvm code :\n* javaOptions.interceptor can be used to surround the call with a custom\n  handling\n* javaOptions.placeHolders allows to define substitution variables\n  (useful mostly for long payloads to avoid StackOverflowErrors)\n* javaOptions.connectionManager allows to specify your own connection\n  manager for pooling purposes or optimization purposes\n  (warning, this will break the trust insecure behavior)\n* javaOptions.httpClientCustomizer lets you manipulate the HttpClientBuilder\n* javaOptions.contextTester allows to inspect the request resolved information (it is a Consumer of HttpContext)\n* javaOptions.simpleArgsParsing uses an alternative regex based args parsing\n  to avoid StackOverflowErrors with very long payloads\n\n```java\ncurl()\n   .javaOptions(with().interceptor(((request, responseSupplier) -\u003e {\n       LOGGER.info(\"I log something before the call\");\n       HttpResponse response = responseSupplier.get();\n       LOGGER.info(\"I log something after the call, status code is {}\",\n       response.getStatusLine().getStatusCode());\n       return response;}))\n                      .connectionManager(new PoolingHttpClientConnectionManager ())\n                      .placeHolders(asList(\"fr-FR\", \"text/html\")).build())\n   .hUpperCase(\"'Accept-Language: $curl_placeholder_0'\")\n   .hUpperCase(\"'Accept: $curl_placeholder_1'\")\n   .run(\"http://www.google.com\");\n```\n\nSupported arguments (so far) :\n\n| Short Name    | Long Name       | Argument Required | Description                                                                                                                                                 |\n| ------------- | --------------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| u             | username        | true              | user:password                                                                                                                                               |\n| cacert        | cacert          | true              | CA_CERT                                                                                                                                                     |\n| E             | cert            | true              | CERT[:password]                                                                                                                                             |\n| ct            | cert-type       | true              | PEM,P12,JKS,DER,ENG                                                                                                                                         |\n| compressed    | compressed      | false             | Request compressed response                                                                                                                                 |\n| cti           | connect-timeout | true              | Maximum time allowed for connection                                                                                                                         |\n| d             | data            | true              | Data                                                                                                                                                        |\n| databinary    | data-binary     | true              | http post binary data                                                                                                                                       |\n| dataurlencode | data-urlencode  | true              | Data to URLEncode                                                                                                                                           |\n| L             | location        | false             | follow redirects                                                                                                                                            |\n| F             | form            | true              | http multipart post data                                                                                                                                    |\n| G             | get             | false             | forces to use GET request method                                                                                                                            |\n| H             | header          | true              | Header                                                                                                                                                      |\n| X             | request         | true              | Http Method                                                                                                                                                 |\n| key           | key             | true              | KEY                                                                                                                                                         |\n| kt            | key-type        | true              | PEM,P12,JKS,DER,ENG                                                                                                                                         |\n| m             | max-time        | true              | Maximum time allowed for the transfer                                                                                                                       |\n| nokeepalive   | no-keepalive    | false             | Disable TCP keepalive on the connection                                                                                                                     |\n| ntlm          | ntlm            | false             | NTLM auth                                                                                                                                                   |\n| o             | output          | true              | write to file                                                                                                                                               |\n| x             | proxy           | true              | use the specified HTTP proxy                                                                                                                                |\n| U             | proxy-user      | true              | authentication for proxy                                                                                                                                    |\n| 1             | tlsv1           | false             | use \u003e        = TLSv1 (SSL)                                                                                                                                  |\n| tlsv10        | tlsv1.0         | false             | use TLSv1.0 (SSL)                                                                                                                                           |\n| tlsv11        | tlsv1.1         | false             | use TLSv1.1 (SSL)                                                                                                                                           |\n| tlsv12        | tlsv1.2         | false             | use TLSv1.2 (SSL)                                                                                                                                           |\n| 2             | sslv2           | false             | use SSLv2 (SSL)                                                                                                                                             |\n| 3             | sslv3           | false             | use SSLv3 (SSL)                                                                                                                                             |\n| k             | insecure        | false             | trust insecure                                                                                                                                              |\n| A             | user-agent      | true              | user agent                                                                                                                                                  |\n| V             | version         | false             | get the version of this library                                                                                                                             |\n| interceptor   | interceptor     | true              | interceptor field or method (syntax is classname::fieldname). Must be a BiFunction\u003cHttpRequest, Supplier\u003c HttpResponse\u003e, HttpResponse\u003e or will be discarded |\n","funding_links":[],"categories":["网络编程"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibetl%2Fcurl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibetl%2Fcurl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibetl%2Fcurl/lists"}