1. <legend id='b6hPY'><style id='b6hPY'><dir id='b6hPY'><q id='b6hPY'></q></dir></style></legend>

        <tfoot id='b6hPY'></tfoot>

        <small id='b6hPY'></small><noframes id='b6hPY'>

          <bdo id='b6hPY'></bdo><ul id='b6hPY'></ul>

        <i id='b6hPY'><tr id='b6hPY'><dt id='b6hPY'><q id='b6hPY'><span id='b6hPY'><b id='b6hPY'><form id='b6hPY'><ins id='b6hPY'></ins><ul id='b6hPY'></ul><sub id='b6hPY'></sub></form><legend id='b6hPY'></legend><bdo id='b6hPY'><pre id='b6hPY'><center id='b6hPY'></center></pre></bdo></b><th id='b6hPY'></th></span></q></dt></tr></i><div id='b6hPY'><tfoot id='b6hPY'></tfoot><dl id='b6hPY'><fieldset id='b6hPY'></fieldset></dl></div>
      2. Curl : * 违反 RFC 2616/10.3.2 并从 POST 切换到 GET

        Curl : * Violate RFC 2616/10.3.2 and switch from POST to GET(Curl : * 违反 RFC 2616/10.3.2 并从 POST 切换到 GET)
          1. <legend id='VUj9r'><style id='VUj9r'><dir id='VUj9r'><q id='VUj9r'></q></dir></style></legend>
            <i id='VUj9r'><tr id='VUj9r'><dt id='VUj9r'><q id='VUj9r'><span id='VUj9r'><b id='VUj9r'><form id='VUj9r'><ins id='VUj9r'></ins><ul id='VUj9r'></ul><sub id='VUj9r'></sub></form><legend id='VUj9r'></legend><bdo id='VUj9r'><pre id='VUj9r'><center id='VUj9r'></center></pre></bdo></b><th id='VUj9r'></th></span></q></dt></tr></i><div id='VUj9r'><tfoot id='VUj9r'></tfoot><dl id='VUj9r'><fieldset id='VUj9r'></fieldset></dl></div>
            <tfoot id='VUj9r'></tfoot>

            <small id='VUj9r'></small><noframes id='VUj9r'>

              <bdo id='VUj9r'></bdo><ul id='VUj9r'></ul>

                    <tbody id='VUj9r'></tbody>
                  本文介绍了Curl : * 违反 RFC 2616/10.3.2 并从 POST 切换到 GET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用 curl 发布到脚本.

                  curl_setopt ($ch, CURLOPT_POST, true);curl_setopt($ch,CURLOPT_URL,$url);curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);curl_setopt($ch,CURLOPT_POSTFIELDS,$postvars);curl_setopt($ch, CURLOPT_VERBOSE, 1);curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);

                  但是涉及 301 重定向,这导致 curl 从 POST 切换到 GET.

                  <前>HTTP/1.1 301 永久移动<位置:https://myserver.org/php/callback-f.php<内容长度:0<日期:2011 年 11 月 16 日,星期三 17:21:06 GMT<服务器:lighttpd/1.4.28* 连接 #0 到主机 myserver.org 保持不变* 向这个 URL 发出另一个请求:'https://myserver.org/php/callback-f.php'* 违反 RFC 2616/10.3.2 并从 POST 切换到 GET* 即将连接()到 myserver.org 端口 443

                  有谁知道如何防止 curl 切换到 GET?

                  解决方案

                  CURLOPT_POSTREDIR 可以设置配置此行为(curl 中基于 301 位置标头的自动重定向的请求方法):

                  <块引用>

                  curl_setopt( , CURLOPT_POSTREDIR, 3);

                  此处 3 告诉 curl 模块重定向 301 和 302 请求.

                  0,1,2,3 是最后一个参数的有效选项.

                  0 ->不要设置任何行为
                  1 ->仅对 301 重定向使用相同类型的请求进行重定向.
                  2 ->仅对 302 重定向使用相同类型的请求进行重定向.
                  3 ->使用相同类型的请求对 301 和 302 重定向进行重定向.

                  另见:请求 #49571 CURLOPT_POSTREDIR 未实现,其中有一些有用的注释,例如设置自定义请求方法:

                  curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "POST");

                  I'm using curl to post to a script.

                  curl_setopt ($ch, CURLOPT_POST, true);
                  curl_setopt($ch,CURLOPT_URL,$url);
                  curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
                  curl_setopt($ch,CURLOPT_POSTFIELDS,$postvars);
                  curl_setopt($ch, CURLOPT_VERBOSE, 1);
                  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
                  curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);
                  

                  But there's 301 redirect involved which casues curl to switch from POST to GET.

                  HTTP/1.1 301 Moved Permanently
                  < Location: https://myserver.org/php/callback-f.php
                  < Content-Length: 0
                  < Date: Wed, 16 Nov 2011 17:21:06 GMT
                  < Server: lighttpd/1.4.28
                  * Connection #0 to host myserver.org left intact
                  * Issue another request to this URL: 'https://myserver.org/php/callback-f.php'
                  * Violate RFC 2616/10.3.2 and switch from POST to GET
                  * About to connect() to myserver.org port 443
                  

                  Does anyone know how I can prevent curl from switching to GET please?

                  解决方案

                  CURLOPT_POSTREDIR can be set to configure this behaviour (request method for 301 location header based automatic redirects in curl):

                  curl_setopt( , CURLOPT_POSTREDIR, 3);

                  here 3 tells curl module to redirect both 301 as well as 302 requests.

                  0,1,2,3 are the valid options for the last argument.

                  0 -> do not set any behavior
                  1 -> follow redirect with the same type of request only for 301 redirects.
                  2 -> follow redirect with the same type of request only for 302 redirects.
                  3 -> follow redirect with the same type of request both for 301 and 302 redirects.

                  See as well: Request #49571 CURLOPT_POSTREDIR not implemented which has some useful comments, like setting a custom request method:

                  curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "POST"); 
                  

                  这篇关于Curl : * 违反 RFC 2616/10.3.2 并从 POST 切换到 GET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                    <i id='OR6g1'><tr id='OR6g1'><dt id='OR6g1'><q id='OR6g1'><span id='OR6g1'><b id='OR6g1'><form id='OR6g1'><ins id='OR6g1'></ins><ul id='OR6g1'></ul><sub id='OR6g1'></sub></form><legend id='OR6g1'></legend><bdo id='OR6g1'><pre id='OR6g1'><center id='OR6g1'></center></pre></bdo></b><th id='OR6g1'></th></span></q></dt></tr></i><div id='OR6g1'><tfoot id='OR6g1'></tfoot><dl id='OR6g1'><fieldset id='OR6g1'></fieldset></dl></div>

                      <tfoot id='OR6g1'></tfoot>
                    1. <small id='OR6g1'></small><noframes id='OR6g1'>

                        <bdo id='OR6g1'></bdo><ul id='OR6g1'></ul>
                          <tbody id='OR6g1'></tbody>
                        • <legend id='OR6g1'><style id='OR6g1'><dir id='OR6g1'><q id='OR6g1'></q></dir></style></legend>