在 64 位 Windows 上运行 cURL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25044010/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Running cURL on 64 bit Windows
提问by Jonathon Nordquist
I'm new to cURL, just got it installed but it seems to only do what it feels like. I'm using the 64 bit version I got from here: http://curl.haxx.se/latest.cgi?curl=win64-ssl-sspiwith installation instructions I found here: http://guides.instructure.com/m/4214/l/83393-how-do-i-install-and-use-curl-on-a-windows-machine. Opening a new Powershell window I'm able to use a simple GET request like so:
我是 cURL 的新手,刚刚安装了它,但它似乎只能做它的感觉。我正在使用从这里获得的 64 位版本:http: //curl.haxx.se/latest.cgi?curl=win64-ssl-sspi以及我在此处找到的安装说明:http: //guides.instructure.com /m/4214/l/83393-how-do-i-install-and-use-curl-on-a-windows-machine。打开一个新的 Powershell 窗口,我可以使用一个简单的 GET 请求,如下所示:
curl http://localhost:3000
but if I run a POST
但如果我运行 POST
curl -d "hello world" http://localhost:3000
it tells me "Invoke-WebRequest : Parameter cannot be processed because the parameter name 'd' is ambiguous. Possible matches include: -DisableKeepAlive -Debug."
它告诉我“Invoke-WebRequest:参数无法处理,因为参数名称‘d’不明确。可能的匹配项包括:-DisableKeepAlive -Debug。”
Trying to get help I type
试图获得帮助我打字
curl -h or curl --help
gives me "Invoke-WebRequest : Missing an argument for parameter 'Headers'. Specify a parameter of type 'System.Collections.IDictionary' and try again."
给我“Invoke-WebRequest:缺少参数'Headers'的参数。指定一个'System.Collections.IDictionary'类型的参数,然后重试。”
As I mentioned, I'm a cURL newbie but it seems strange that it can do get requests but nothing else. Any ideas what I'm doing wrong?
正如我所提到的,我是一个 cURL 新手,但它可以获取请求但没有其他功能似乎很奇怪。任何想法我做错了什么?
Windows 7 64 bit Powershell version 4
Windows 7 64 位 Powershell 版本 4
回答by JPBlanc
Your problem is that your are not using the Curl
you installed but a CmdLet called Invoke-WebRequest
.
你的问题是你没有使用Curl
你安装的,而是一个名为Invoke-WebRequest
.
Just execute :
只需执行:
Remove-item alias:curl
And test your curl again, then store it in your profile.
并再次测试您的 curl,然后将其存储在您的配置文件中。
The explanation is that it exists a native alias to the Invoke-WebRequest
which is a CmdLet that is supposed to deliver a kind ofcurl service.
解释是它存在一个本地别名,Invoke-WebRequest
它是一个应该提供一种curl 服务的 CmdLet 。
From Windows 10 build 17063 and later (April 2018), Curl
is included into Windows, so that you can execute it directly from Cmd.exe or PowerShell.exe. To use it in PowerShell be careful to unalias this CmdLet or explicitly call curl.exe.
从 Windows 10 内部版本 17063 及更高版本(2018 年 4 月)开始,Curl
包含在 Windows 中,以便您可以直接从 Cmd.exe 或 PowerShell.exe 执行它。要在 PowerShell 中使用它,请小心取消此 CmdLet 的别名或显式调用 curl.exe。
Built with Schannel (Microsoft's native TLS engine), libcurl still perform peer certificate verification, but instead of using a CA cert bundle, it uses the certificates that are built into the OS.
使用 Schannel(微软的原生 TLS 引擎)构建,libcurl 仍然执行对等证书验证,但它使用操作系统内置的证书而不是使用 CA 证书包。