linux curl请求时参数被截断

栏目: 服务器 · 发布时间: 6年前

内容简介:当我在这导致了我的认证失败,无法获取正确的数据。其实这里的原因是在

当我在 curl 一个 url 时,发现在后端 PHP 环境使用 xdebug 时,只能捕获第一个参数:

curl test.baidu.com/oss/index.php?r=info/data/query&username=xxx&password=xxx
# 在后端url被截断,只能捕获到第一个参数
$_GET: array(1) r: "info/data/query"

这导致了我的认证失败,无法获取正确的数据。

其实这里的原因是在 shell 命令中 & 符号有特殊的含义,而并不只是 url 参数的连接符。因此,我们有两种解决方法:

# 方法一:转义,加上\符
curl test.baidu.com/oss/index.php?r=info/data/query\&username=xxx\&password=xxx
# 方法二:包装,在url外加上引号,用字符串处理
curl 'test.baidu.com/oss/index.php?r=info/data/query&username=xxx&password=xxx'

重新测试,解决问题。

参考资料

  1. Linux curl get请求参数多个参数被截断的解决方法: https://blog.csdn.net/top_cod...

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Discrete Mathematics and Its Applications

Discrete Mathematics and Its Applications

Kenneth H Rosen / McGraw-Hill Science/Engineering/Math / 2003-04-22 / USD 132.81

Discrete Mathematics and its Applications is a focused introduction to the primary themes in a discrete mathematics course, as introduced through extensive applications, expansive discussion, and deta......一起来看看 《Discrete Mathematics and Its Applications》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

HSV CMYK 转换工具
HSV CMYK 转换工具

HSV CMYK互换工具