特殊字符(如@和&在cURL POST数据 [英] Special characters like @ and & in cURL POST data

查看:270
本文介绍了特殊字符(如@和&在cURL POST数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何添加特殊字符(如@和&在cURL POST数据?我想传递一个名称和密码,如:

How do I include special characters like @ and & in the cURL POST data? I'm trying to pass a name and password like:

curl -d name=john passwd=@31&3*J https://www.mysite.com

这会导致问题,因为 @ 用于加载文件,& 用于指定多个键/值。有没有一些方法,我可以逃脱这些人物? \ @ \& 似乎无效。

This would cause problems as @ is used for loading files and & for specifying more than one key/value. Is there some way I can escape these characters? \@ and \& don't seem to work.

推荐答案

cURL> 7.18.0有一个选项 - data-urlencode 来解决这个问题。使用这个,我可以简单地发送POST请求作为

cURL > 7.18.0 has an option --data-urlencode which solves this problem. Using this, I can simply send a POST request as

curl -d name=john --data-urlencode passwd=@31&3*J https://www.mysite.com

这篇关于特殊字符(如@和&在cURL POST数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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