linux curl请求时参数被截断

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

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

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

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

查看所有标签

猜你喜欢:

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

Head Rush Ajax

Head Rush Ajax

Brett McLaughlin、Eric Freeman、Elisabeth Freeman / O'Reilly Media, Inc. / 2006-03-01 / USD 34.99

Ajax, or Asynchronous JavaScript and XML, is a term describing the latest rage in web development. Ajax is used to create interactive web applications with XML-based web services, and using JavaScript......一起来看看 《Head Rush Ajax》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

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

URL 编码/解码

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具