{"id":13505042,"url":"https://github.com/vzsg/Curly","last_synced_at":"2025-03-29T22:31:24.440Z","repository":{"id":63921231,"uuid":"169619076","full_name":"vzsg/Curly","owner":"vzsg","description":"Embrace the power of curl in Vapor 3 apps","archived":false,"fork":false,"pushed_at":"2020-06-02T12:13:36.000Z","size":80,"stargazers_count":27,"open_issues_count":2,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-18T05:51:20.493Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vzsg.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-02-07T18:16:03.000Z","updated_at":"2024-08-28T20:05:15.000Z","dependencies_parsed_at":"2023-01-14T14:15:14.773Z","dependency_job_id":null,"html_url":"https://github.com/vzsg/Curly","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vzsg%2FCurly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vzsg%2FCurly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vzsg%2FCurly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vzsg%2FCurly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vzsg","download_url":"https://codeload.github.com/vzsg/Curly/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246254077,"owners_count":20747946,"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-01T00:00:57.439Z","updated_at":"2025-03-29T22:31:23.456Z","avatar_url":"https://github.com/vzsg.png","language":"Swift","funding_links":[],"categories":["Packages"],"sub_categories":["Miscellaneous"],"readme":"# Curly\n\nThis package wraps [Perfect-CURL](https://github.com/PerfectlySoft/Perfect-CURL) into a Vapor 3 `Client`. If you are running into issues with URLSession on Linux, or you want cookies or proxy support, this might be the way out.\n\n## Usage\n\n### 0. (Linux) Install libcurl development package\n\nThis package relies on the development package for libcurl4. Make sure you have `libcurl4-openssl-dev` installed before trying to build your Swift project.\n\n```\nsudo apt-get update\nsudo apt-get install libcurl4-openssl-dev\n```\n\n### 1. Add this package as a dependency to your Vapor 3 project\n\n```swift\n// swift-tools-version:4.0\nimport PackageDescription\n\nlet package = Package(\n    name: \"VaporApp\",\n    dependencies: [\n        // 💧 A server-side Swift web framework.\n        .package(url: \"https://github.com/vapor/vapor.git\", from: \"3.0.0\"),\n        .package(url: \"https://github.com/vzsg/Curly.git\", from: \"0.6.0\"),\n        // ... other dependencies ...\n    ],\n    targets: [\n        .target(name: \"App\", dependencies: [\"Vapor\", \"...\", \"CurlyClient\"]),\n        // ... other targets ...\n    ]\n)\n```\n\n### 2. Register the CurlyProvider\n\n```swift\n// Typically, this is part of configure.swift\nimport Vapor\nimport CurlyClient\n// ... other imports ...\n\n\npublic func configure(_ config: inout Config, _ env: inout Environment, _ services: inout Services) throws {\n    try services.register(CurlyProvider())\n    config.prefer(CurlyClient.self, for: Client.self)\n\n    // ... other configuration ...\n}\n```\n\n### 3. Profit!\n\nYour Vapor app now uses curl directly instead of URLSession.\n\n### 4. Extra profit: CurlyOptions\n\nFrom 0.3.0, Curly exposes a few useful options from cURL that are otherwise not available via the Client interface, or even URLSession. To use them, you _must_ register Curly via the `CurlyProvider` as seen in step 2.\n\nWith that in place, you can call `Request.addCurlyOption` in either the `beforeSend` closure when using the convenience functions of Client, or on the Request instance itself when using `Client.send()` and a self-built Request object.  \nThe two approaches are functionally equivalent.\n\n```swift\ntry client.get(\"https://self-signed.badssl.com/\", beforeSend: { req in\n    req.addCurlyOption(.sslVerifyPeer(false))\n})\n```\n\n```swift\nvar http = HTTPRequest(method: .GET, url: \"https://self-signed.badssl.com/\")\nhttp.headers.replaceOrAdd(name: \"X-Test-Header\", value: \"Foo\")\n\nlet req = Request(http: http, using: app)\nreq.addCurlyOption(.sslVerifyPeer(false))\n\ntry client.send(req)\n```\n\n\u003e **Warning**: Calling `Request.addCurlyOption` without the Provider will result in a fatal error in debug builds, and a warning print in release builds.\n\nStarting with 0.7.0, options can be applied to all requests made via Curly using the new `globalOptions` optional parameter of CurlyProvider.\n\n```swift\ntry services.register(CurlyProvider(globalOptions: [\n    .sslCAFilePath(\"my-selfsigned-certs.crt\")\n]))\n```\n\n#### Available options\n\n- **proxy(String)**\n\n    Equivalent to the [`-x`/`--proxy`](https://curl.haxx.se/docs/manpage.html#-x) parameter of curl, which enables proxying via a HTTP, HTTPS or SOCKS proxy.\n\n- **proxyAuth(user: String, password: String)**\n\n    Equivalent to the [`-U`/`--proxy-user`](https://curl.haxx.se/docs/manpage.html#-U) parameter of curl, which allows specifying the username and password to use when authenticating to the proxy server.\n\n- **proxyPort(Int)** (New in 0.6.0)\n\n    Equivalent to `CURLOPT_PROXYPORT`, which allows separately overriding the port used to connect to the proxy.\n\n- **timeout(Int)**\n\n    Equivalent to the [`-m`/`--max-time`](https://curl.haxx.se/docs/manpage.html#-m) parameter of curl, which allows specifying the maximum time allowed to service the request in seconds.\n\n- **timeoutMs(Int)**\n\n    Same as `timeout`, but with milliseconds precision.\n\n- **connectTimeout(Int)**\n\n    Equivalent to the [`--connect-timeout`](https://curl.haxx.se/docs/manpage.html#--connect-timeout) parameter of curl, which allows specifying the maximum time allowed for the connection to the server in seconds.\n\n- **connectTimeoutMs(Int)** (New in 0.5.0)\n\n    Same as `connectTimeout`, but with milliseconds precision.\n\n- **cookieJar(String)**\n\n    Equivalent to setting **both** the [`-b`/`--cookie`](https://curl.haxx.se/docs/manpage.html#-b) **and** [`-c`/`--cookie-jar`](https://curl.haxx.se/docs/manpage.html#-c) parameters of curl. The file name provided with the option will be used as a cookie storage – reading and writing – for this request. See the tests for an example.\n\n- **followRedirects(Bool)**\n\n    Equivalent to the [`-L`/`--location`](https://curl.haxx.se/docs/manpage.html#-L) parameter of curl, which enables following redirects automatically.\n\n- **insecure(Bool)**\n\n    Equivalent to the [`-k`/`--insecure`](https://curl.haxx.se/docs/manpage.html#-k) parameter of curl, which can disable verification of the certificates received from the remote server. Deprecated in favor of `sslVerifyPeer`.\n\n- **sslVerifyPeer(Bool)** (New in 0.6.0)\n\n    Equivalent to [`CURLOPT_SSL_VERIFYPEER`](https://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYPEER.html]), used to enable or disable server certificate verification.\n\n- **sslVerifyHost(Bool)** (New in 0.6.0)\n\n    Equivalent to [`CURLOPT_SSL_VERIFYHOST`](https://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYHOST.html]), used to enable or disable verification of the server host name against the server certificates.\n\n- **sslKey(path: String, type: CurlySSLFileType?, password: String?)** (New in 0.6.0)\n\n    Equivalent to the [`--key`](https://curl.haxx.se/docs/manpage.html#--key), [`--key-type`](https://curl.haxx.se/docs/manpage.html#--key-type) and [`--pass`](https://curl.haxx.se/docs/manpage.html#--pass) parameters, used to specify a private key to use for client certificate verification.\n\n- **sslCert(path: String, type: CurlySSLFileType?)** (New in 0.6.0)\n\n    Equivalent to the [`-E`/`--cert`](https://curl.haxx.se/docs/manpage.html#-E) and [`--cert-type`](https://curl.haxx.se/docs/manpage.html#--cert-type) parameters, used to specify a client certificate.\n\n- **sslCAFilePath(String)** (New in 0.6.0)\n\n    Equivalent to the [`--cacert`](https://curl.haxx.se/docs/manpage.html#--cacert) parameter, used to specify a certificate to verify the server certificates against.\n\n- **sslCADirPath(String)** (New in 0.6.0)\n\n    Equivalent to the [`--cadir`](https://curl.haxx.se/docs/manpage.html#--cadir) parameter, used to specify a folder containing certificates to verify the server certificates against.\n\n- **sslCiphers([String])** (New in 0.6.0)\n\n    Equivalent to the [`--ciphers`](https://curl.haxx.se/docs/manpage.html#--ciphers) parameter, used to specify which ciphers to allow. See [this page](https://curl.haxx.se/docs/ssl-ciphers.html) for details.\n\n- **sslPinnedPublicKey(String)** (New in 0.6.0)\n\n    Equivalent to the [`--pinnedpubkey`](https://curl.haxx.se/docs/manpage.html#--pinnedpubkey) parameter, used to specify either a file with a PEM/DER encoded public key, or an SHA-256 hash that the server must present in its certificate chain.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvzsg%2FCurly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvzsg%2FCurly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvzsg%2FCurly/lists"}