在 64 位 Windows 上运行 cURL [英] Running cURL on 64 bit Windows

查看:45
本文介绍了在 64 位 Windows 上运行 cURL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 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 请求:

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-sspi with 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 http://localhost:3000

但是如果我运行 POST

but if I run a POST

curl -d "hello world" http://localhost:3000

它告诉我Invoke-WebRequest:无法处理参数,因为参数名称‘d’不明确.可能的匹配项包括:-DisableKeepAlive -Debug."

it tells me "Invoke-WebRequest : Parameter cannot be processed because the parameter name 'd' is ambiguous. Possible matches include: -DisableKeepAlive -Debug."

试图获得帮助我输入

curl -h or curl --help

给我Invoke-WebRequest:缺少参数'Headers'的参数.指定一个'System.Collections.IDictionary'类型的参数,然后重试."

gives me "Invoke-WebRequest : Missing an argument for parameter 'Headers'. Specify a parameter of type 'System.Collections.IDictionary' and try again."

正如我所提到的,我是一个 cURL 新手,但它只能获取请求似乎很奇怪.知道我做错了什么吗?

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?

Windows 7 64 位Powershell 版本 4

Windows 7 64 bit Powershell version 4

推荐答案

你的问题是你没有使用你安装的 Curl 而是一个名为 Invoke-WebRequest 的 CmdLet.

Your problem is that your are not using the Curl you installed but a CmdLet called Invoke-WebRequest.

只要执行:

Remove-item alias:curl

再次测试您的 curl,然后将其存储在您的个人资料中.

And test your curl again, then store it in your profile.

解释是它存在 Invoke-WebRequest 的本地别名,它是一个 CmdLet,应该提供 一种 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 of curl service.

从 Windows 10 build 17063 及更高版本(2018 年 4 月)开始,Curl 包含在 Windows 中,因此您可以直接从 Cmd.exe 或 PowerShell.exe 执行它.要在 PowerShell 中使用它,请小心取消此 CmdLet 的别名或显式调用 curl.exe.

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.

与 Schannel(微软的原生 TLS 引擎)一起构建,libcurl 仍然执行对等证书验证,但它不使用 CA 证书包,而是使用操作系统内置的证书.

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.

这篇关于在 64 位 Windows 上运行 cURL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆