### 问题描述 代码部署到服务器后,curl发送POST请求,返回400状态码,经本地测试发现无法复现。 ### 问题排查 排查个鬼,玄学得一批,查到头皮发麻。于是乎,又到了万能的百度出手了,经过了大量查阅,终于发现了问题所在。问题出在于在Linux下如果发送空请求参数的时候不能使用`curl_setopt($ch, CURLOPT_POST, true)`来设置为POST请求,如果确有需要,可以用`curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST')`代替,但是如果我们使用别人提供的类库进行请求咋办呢,这时候只能随便加个参数上去,不要发送空请求就好了,比如随便加个`t=xxxxxx`。
### 当前已安装的gcc版本 ```shell liesauer@LA-Tower:/mnt/o/Projects/core-setup$ clang++-3.9 -v clang version 3.9.1-19ubuntu1 (tags/RELEASE_391/rc2) Target: x86_64-pc-linux-gnu Thread model: posix InstalledDir: /usr/bin Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8 Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8.5 Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7 Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5 Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.5 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8 Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5 Candidate multilib: .;@m64 Selected multilib: .;@m64 ``` ### 常规方式切换 通过网上大量查阅资料,发现都是通过设置环境变量或者传递参数到clang++实现gcc版本切换,但由于我是使用提供的脚本进行编译,各种环境变量都被脚本控制得死死的,而且编译前都要进行`git reset --hard HEAD`,所以修改编译脚本也不现实。 - 阅读剩余部分 -
- 阅读剩余部分 -
服务器推荐