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

Viewed 783

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. For example if you try to go to this link of Telegram custom protocol scheme on cURL:

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

I've searched through the curl man page and couldn't find anything about it. Is there a way to enable custom URL schemes for cURL or cURL just doesn't have that kind of functionality?

Edit: The same goes for Powershell cmdlets like Invoke-WebRequest and Invoke-RestMethod.

Edit 2: I want cURL to invoke my custom URL scheme, not Telegram scheme in particular.

1 Answers

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:

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

curl supports these protocols

PROTOCOLS

curl supports numerous protocols, or put in URL terms: schemes. 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.

FTP(S)

curl supports the File Transfer Protocol with a lot of tweaks and levers. With or without using TLS.

GOPHER

Retrieve files.

HTTP(S)

curl supports HTTP with numerous options and variations. It can speak HTTP version 0.9, 1.0, 1.1, 2 and 3 depending on build options and the correct command line options.

IMAP(S)

Using the mail reading protocol, curl can "download" emails for you. With or without using TLS.

LDAP(S)

curl can do directory lookups for you, with or without TLS.

MQTT

curl supports MQTT version 3. Downloading over MQTT equals "subscribe" to a topic while uploading/posting equals "publish" on a topic. MQTT support is experimental and TLS based MQTT is not supported (yet).

POP3(S)

Downloading from a pop3 server means getting a mail. With or without using TLS.

RTMP(S)

The Realtime Messaging Protocol is primarily used to server streaming media and curl can download it.

RTSP

curl supports RTSP 1.0 downloads.

SCP

curl supports SSH version 2 scp transfers.

SFTP

curl supports SFTP (draft 5) done over SSH version 2.

SMB(S)

curl supports SMB version 1 for upload and download.

SMTP(S)

Uploading contents to an SMTP server means sending an email. With or without 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.

TFTP

curl can do TFTP downloads and uploads.

Your telegram protocol is not among those supported, thus you are getting the error.

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. This supports only HTTP or HTTPS only. For more see ms docs on Invoke-WebRequest.

The Invoke-RestMethod is similar to Invoke-WebRequest as it sends an HTTP or HTTPS request to a RESTful web service. The difference is in the RESTful part.

Conclusion

You are out of luck, unless somebody decides to add the tg:// protocol support into the unix/linux curl.

Related