{"id":13440175,"url":"https://github.com/alexcrichton/curl-rust","last_synced_at":"2025-05-14T00:04:36.584Z","repository":{"id":39634145,"uuid":"20513654","full_name":"alexcrichton/curl-rust","owner":"alexcrichton","description":"Rust bindings to libcurl","archived":false,"fork":false,"pushed_at":"2025-02-25T05:31:40.000Z","size":2748,"stargazers_count":1043,"open_issues_count":80,"forks_count":240,"subscribers_count":23,"default_branch":"main","last_synced_at":"2025-05-03T01:55:26.633Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/alexcrichton.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}},"created_at":"2014-06-05T06:00:53.000Z","updated_at":"2025-04-27T08:01:13.000Z","dependencies_parsed_at":"2024-06-18T12:30:04.061Z","dependency_job_id":"2824dc9c-315f-44b8-a319-cc35247f0cd5","html_url":"https://github.com/alexcrichton/curl-rust","commit_stats":{"total_commits":807,"total_committers":129,"mean_commits":6.255813953488372,"dds":0.4225526641883519,"last_synced_commit":"cd649f2490cd1ba39b5d2cfb0ab4a23d843195d2"},"previous_names":["carllerche/curl-rust"],"tags_count":166,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcrichton%2Fcurl-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcrichton%2Fcurl-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcrichton%2Fcurl-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexcrichton%2Fcurl-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexcrichton","download_url":"https://codeload.github.com/alexcrichton/curl-rust/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254043219,"owners_count":22004912,"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-07-31T03:01:20.425Z","updated_at":"2025-05-14T00:04:36.546Z","avatar_url":"https://github.com/alexcrichton.png","language":"Rust","funding_links":[],"categories":["Libraries","Rust","库 Libraries","库","Recently Updated","Programming Languages"],"sub_categories":["Web programming","网络编程 Web programming","网页编程","[Apr 03, 2025](/content/2025/04/03/README.md)","web编程 Web programming","Rust"],"readme":"# curl-rust\n\n[libcurl] bindings for Rust\n\n[![Latest Version](https://img.shields.io/crates/v/curl.svg)](https://crates.io/crates/curl)\n[![Documentation](https://docs.rs/curl/badge.svg)](https://docs.rs/curl)\n[![License](https://img.shields.io/github/license/alexcrichton/curl-rust.svg)](LICENSE)\n[![Build](https://github.com/alexcrichton/curl-rust/workflows/CI/badge.svg)](https://github.com/alexcrichton/curl-rust/actions)\n\n## Quick Start\n\n```rust\nuse std::io::{stdout, Write};\n\nuse curl::easy::Easy;\n\n// Print a web page onto stdout\nfn main() {\n    let mut easy = Easy::new();\n    easy.url(\"https://www.rust-lang.org/\").unwrap();\n    easy.write_function(|data| {\n        stdout().write_all(data).unwrap();\n        Ok(data.len())\n    }).unwrap();\n    easy.perform().unwrap();\n\n    println!(\"{}\", easy.response_code().unwrap());\n}\n```\n\n```rust\nuse curl::easy::Easy;\n\n// Capture output into a local `Vec`.\nfn main() {\n    let mut dst = Vec::new();\n    let mut easy = Easy::new();\n    easy.url(\"https://www.rust-lang.org/\").unwrap();\n\n    let mut transfer = easy.transfer();\n    transfer.write_function(|data| {\n        dst.extend_from_slice(data);\n        Ok(data.len())\n    }).unwrap();\n    transfer.perform().unwrap();\n}\n```\n\n## Post / Put requests\n\nThe `put` and `post` methods on `Easy` can configure the method of the HTTP\nrequest, and then `read_function` can be used to specify how data is filled in.\nThis interface works particularly well with types that implement `Read`.\n\n```rust,no_run\nuse std::io::Read;\nuse curl::easy::Easy;\n\nfn main() {\n    let mut data = \"this is the body\".as_bytes();\n\n    let mut easy = Easy::new();\n    easy.url(\"http://www.example.com/upload\").unwrap();\n    easy.post(true).unwrap();\n    easy.post_field_size(data.len() as u64).unwrap();\n\n    let mut transfer = easy.transfer();\n    transfer.read_function(|buf| {\n        Ok(data.read(buf).unwrap_or(0))\n    }).unwrap();\n    transfer.perform().unwrap();\n}\n```\n\n## Custom headers\n\nCustom headers can be specified as part of the request:\n\n```rust,no_run\nuse curl::easy::{Easy, List};\n\nfn main() {\n    let mut easy = Easy::new();\n    easy.url(\"http://www.example.com\").unwrap();\n\n    let mut list = List::new();\n    list.append(\"Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==\").unwrap();\n    easy.http_headers(list).unwrap();\n    easy.perform().unwrap();\n}\n```\n\n## Keep alive\n\nThe handle can be re-used across multiple requests. Curl will attempt to\nkeep the connections alive.\n\n```rust,no_run\nuse curl::easy::Easy;\n\nfn main() {\n    let mut handle = Easy::new();\n\n    handle.url(\"http://www.example.com/foo\").unwrap();\n    handle.perform().unwrap();\n\n    handle.url(\"http://www.example.com/bar\").unwrap();\n    handle.perform().unwrap();\n}\n```\n\n## Multiple requests\n\nThe libcurl library provides support for sending multiple requests\nsimultaneously through the \"multi\" interface. This is currently bound in the\n`multi` module of this crate and provides the ability to execute multiple\ntransfers simultaneously. For more information, see that module.\n\n## Building\n\nBy default, this crate will attempt to dynamically link to the system-wide\nlibcurl and the system-wide SSL library. Some of this behavior can be customized\nwith various Cargo features:\n\n- `ssl`: Enable SSL/TLS support using the platform-default TLS backend. On Windows this is [Schannel], on macOS [Secure Transport], and [OpenSSL] (or equivalent) on all other platforms.  Enabled by default.\n- `rustls` Enable SSL/TLS support via [Rustls], a well-received alternative TLS backend written in Rust. Rustls is always statically linked. Disabled by default.\n\n  Note that Rustls support is experimental within Curl itself and may have significant bugs, so we don't offer any sort of stability guarantee with this feature.\n- `http2`: Enable HTTP/2 support via libnghttp2. Disabled by default.\n- `static-curl`: Use a bundled libcurl version and statically link to it. Disabled by default.\n- `static-ssl`: Use a bundled OpenSSL version and statically link to it. Only applies on platforms that use OpenSSL. Disabled by default.\n- `spnego`: Enable SPNEGO support. Disabled by default.\n- `upkeep_7_62_0`: Enable curl_easy_upkeep() support, introduced in curl 7.62.0. Disabled by default.\n- `poll_7_68_0`: Enable curl_multi_poll()/curl_multi_wakeup() support, requires curl 7.68.0 or later. Disabled by default.\n- `ntlm`: Enable NTLM support in curl. Disabled by default.\n- `windows-static-ssl`: Enable Openssl support on Windows via the static build provided by vcpkg. Incompatible with `ssl` (use `--no-default-features`). Disabled by default.\n\n  Note that to install openssl on windows via vcpkg the following commands needs to be ran:\n  ```shell\n  git clone https://github.com/microsoft/vcpkg\n  cd vcpkg\n  ./bootstrap-vcpkg.bat -disableMetrics\n  ./vcpkg.exe integrate install\n  ./vcpkg.exe install openssl:x64-windows-static-md\n  ```\n\n## Version Support\n\nThe bindings have been developed using curl version 7.24.0. They should\nwork with any newer version of curl and possibly with older versions,\nbut this has not been tested.\n\n## Troubleshooting\n\n### Curl built against the NSS SSL library\n\nIf you encounter the following error message:\n\n```\n  [77] Problem with the SSL CA cert (path? access rights?)\n```\n\nThat means most likely, that curl was linked against `libcurl-nss.so` due to\ninstalled libcurl NSS development files, and that the required library\n`libnsspem.so` is missing. See also the curl man page: \"If curl is built\nagainst the NSS SSL library, the NSS PEM PKCS#11 module (`libnsspem.so`) needs to be available for this option to work properly.\"\n\nIn order to avoid this failure you can either\n\n * install the missing library (e.g. Debian: `nss-plugin-pem`), or\n * remove the libcurl NSS development files (e.g. Debian: `libcurl4-nss-dev`) and\n   rebuild curl-rust.\n\n## License\n\nThe `curl-rust` crate is licensed under the MIT license, see [`LICENSE`](LICENSE) for more\ndetails.\n\n\n[libcurl]: https://curl.haxx.se/libcurl/\n[OpenSSL]: https://www.openssl.org/\n[Rustls]: https://github.com/ctz/rustls\n[Schannel]: https://docs.microsoft.com/en-us/windows/win32/com/schannel\n[Secure Transport]: https://developer.apple.com/documentation/security/secure_transport\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexcrichton%2Fcurl-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexcrichton%2Fcurl-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexcrichton%2Fcurl-rust/lists"}