简体   繁体   English

如何为 curl Rust crate 启用 NTLM 支持?

[英]How to enable NTLM support for curl Rust crate?

I build on windows with cargo.toml settings:我在带有 cargo.toml 设置的 Windows 上构建:

[dependencies]
curl = {version="0.4.33", features = ["ssl"]}

Then when I call http service I get an error:然后当我调用 http 服务时出现错误:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error 
{ description: "A requested feature, protocol or option was not found built-in in this libcurl 
due to a build-time decision.", code: 4, extra: None }'

How to enable NTLM support for curl Rust crate?如何为 curl Rust crate 启用 NTLM 支持?

The rust curl crate will attempt to link against the existing curl library on your system if it can find it.如果可以找到, rust curl crate将尝试链接到系统上现有的 curl 库。 In that case, you will only be able to use features which are compiled into that existing curl library.在这种情况下,您将只能使用编译到现有 curl 库中的功能。

Going by the error you are getting, I would assume that NTLM was not enabled when your curl library was compiled.根据您遇到的错误,我假设编译 curl 库时未启用 NTLM。 You can check that by running the curl cli progam (which is usually linked to the library) with the -V option:您可以通过使用-V选项运行 curl cli 程序(通常链接到库)来检查:

$ curl -V
curl 7.43.0 (x86_64-redhat-linux-gnu) libcurl/7.43.0 NSS/3.19.1 Basic ECC zlib/1.2.7 libidn/1.28 libssh2/1.8.0
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets Metalink

If you enable the crate feature static-curl then it will build the curl library itself and statically link it.如果您启用 crate 功能static-curl那么它将构建 curl 库本身并静态链接它。 It appears that it will enable all applicable features in that scenario (although I have not tested that).似乎它将启用该场景中的所有适用功能(尽管我尚未对此进行测试)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM