linux curl请求时参数被截断

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

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

当我在 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...

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

查看所有标签

猜你喜欢:

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

A Byte of Python

A Byte of Python

Swaroop C H / Lulu Marketplace / 2008-10-1 / USD 27.98

'A Byte of Python' is a book on programming using the Python language. It serves as a tutorial or guide to the Python language for a beginner audience. If all you know about computers is how to save t......一起来看看 《A Byte of Python》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具