简体   繁体   English

有没有办法为 cURL 启用自定义 URL 方案支持?

[英]Is there a way to enable custom URL scheme support for cURL?

I've made an app with its own custom URL scheme and I've noticed that cURL doesn't recognize custom URL schemes at all.我用自己的自定义 URL 方案制作了一个应用程序,我注意到 cURL 根本无法识别自定义 URL 方案。 For example if you try to go to this link of Telegram custom protocol scheme on cURL:例如,如果您尝试 go 到 cURL 上的 Telegram 自定义协议方案的此链接:

curl --url tg://resolve?domain=telegram

it doesn't work at all with the error stating:它根本不起作用,错误说明:

curl: (1) Protocol "tg" not supported or disabled in libcurl curl:(1)libcurl 中不支持或禁用协议“tg”

I've searched through the curl man page and couldn't find anything about it.我搜索了 curl 手册页,但找不到任何相关信息。 Is there a way to enable custom URL schemes for cURL or cURL just doesn't have that kind of functionality?有没有办法为 cURL 或 cURL 启用自定义 URL 方案只是没有那种功能?

Edit: The same goes for Powershell cmdlets like Invoke-WebRequest and Invoke-RestMethod.编辑:同样适用于 Powershell cmdlet,如 Invoke-WebRequest 和 Invoke-RestMethod。

Edit 2: I want cURL to invoke my custom URL scheme, not Telegram scheme in particular.编辑 2:我希望 cURL 调用我的自定义 URL 方案,而不是特别是电报方案。

I think you are mixing two or more things together.我认为您将两种或多种事物混合在一起。 First you have a unix program called curl which will, if you have the unix program in windows give you:首先,您有一个名为 unix 的程序,称为curl ,如果您在 Z0F4137ED1502B5045D6083CAA2 中有 unix 程序,那么您将给出:

C:\>curl --url tg://resolve?domain=telegram
curl: (1) Protocol "tg" not supported or disabled in libcurl

curl supports these protocols curl支持这些协议

PROTOCOLS协议

curl supports numerous protocols, or put in URL terms: schemes. curl 支持多种协议,或者放入 URL 术语:方案。 Your particular build may not support them all.您的特定版本可能无法全部支持。

DICT信息和通信技术

Lets you lookup words using online dictionaries.让您使用在线词典查找单词。

FILE文件

Read or write local files.读取或写入本地文件。 curl does not support accessing file:// URL remotely, but when running on Microsoft Windows using the native UNC approach will work. curl 不支持远程访问 file:// URL,但是在 Microsoft Windows 上运行时使用本机 UNC 方法将起作用。

FTP(S) FTP(S)

curl supports the File Transfer Protocol with a lot of tweaks and levers. curl 通过大量调整和杠杆支持文件传输协议。 With or without using TLS.使用或不使用 TLS。

GOPHER地鼠

Retrieve files.检索文件。

HTTP(S) HTTP(S)

curl supports HTTP with numerous options and variations. curl 支持 HTTP,具有多种选项和变化。 It can speak HTTP version 0.9, 1.0, 1.1, 2 and 3 depending on build options and the correct command line options.它可以使用 HTTP 版本 0.9、1.0、1.1、2 和 3,具体取决于构建选项和正确的命令行选项。

IMAP(S) IMAP(S)

Using the mail reading protocol, curl can "download" emails for you.使用邮件阅读协议,curl 可以为您“下载”电子邮件。 With or without using TLS.使用或不使用 TLS。

LDAP(S) LDAP(S)

curl can do directory lookups for you, with or without TLS. curl 可以为您进行目录查找,无论是否使用 TLS。

MQTT MQTT

curl supports MQTT version 3. Downloading over MQTT equals "subscribe" to a topic while uploading/posting equals "publish" on a topic. curl 支持 MQTT 版本 3。通过 MQTT 下载等于“订阅”主题,而上传/发布等于“发布”主题。 MQTT support is experimental and TLS based MQTT is not supported (yet). MQTT 支持是实验性的,不支持基于 TLS 的 MQTT(尚)。

POP3(S) POP3(小)

Downloading from a pop3 server means getting a mail.从 pop3 服务器下载意味着收到邮件。 With or without using TLS.使用或不使用 TLS。

RTMP(S) RTMP(S)

The Realtime Messaging Protocol is primarily used to server streaming media and curl can download it. Realtime Messaging Protocol 主要用于流媒体服务器,curl 可以下载。

RTSP RTSP

curl supports RTSP 1.0 downloads. curl 支持 RTSP 1.0 下载。

SCP SCP

curl supports SSH version 2 scp transfers. curl 支持 SSH 版本 2 scp 传输。

SFTP SFTP

curl supports SFTP (draft 5) done over SSH version 2. curl 支持在 SSH 版本 2 上完成的 SFTP(草案 5)。

SMB(S)中小企业

curl supports SMB version 1 for upload and download. curl 支持 SMB 版本 1 进行上传和下载。

SMTP(S) SMTP(S)

Uploading contents to an SMTP server means sending an email.将内容上传到 SMTP 服务器意味着发送 email。 With or without TLS.有或没有 TLS。

TELNET远程网络

Telling curl to fetch a telnet URL starts an interactive session where it sends what it reads on stdin and outputs what the server sends it.告诉 curl 获取 telnet URL 启动交互式 session 发送它在标准输入上读取的内容并输出服务器发送的内容。

TFTP TFTP

curl can do TFTP downloads and uploads. curl可以做TFTP下载和上传。

Your telegram protocol is not among those supported, thus you are getting the error.您的电报协议不在受支持的协议中,因此您收到错误消息。

PowerShell output: PowerShell output:

curl --url tg://resolve?domain=telegram curl: (1) Protocol "tg" not supported or disabled in libcurl
Invoke-WebRequest : A positional parameter cannot be found that accepts argument 'tg://resolve?domain=te legram'.
At line:1 char:1
+ curl --url tg://resolve?domain=telegram curl: (1) Protocol "tg" not s ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebReques
   tCommand

The second part is the curl in powershell which is just alias for Invoke-WebRequest .第二部分是curl中的 curl ,它只是Invoke-WebRequest别名。 This supports only HTTP or HTTPS only.这仅支持 HTTP 或 HTTPS。 For more see ms docs on Invoke-WebRequest .有关更多信息,请参阅Invoke-WebRequest上的 ms 文档

The Invoke-RestMethod is similar to Invoke-WebRequest as it sends an HTTP or HTTPS request to a RESTful web service. Invoke-RestMethod类似于Invoke-WebRequest ,因为它向 RESTful web 服务发送 HTTP 或 HTTPS 请求。 The difference is in the RESTful part.不同之处在于 RESTful 部分。

Conclusion结论

You are out of luck, unless somebody decides to add the tg:// protocol support into the unix/linux curl .你不走运,除非有人决定将tg://协议支持添加到 unix/linux curl中。

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

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