0

cURL 経由で HTTP リクエストを送信していますが、この 413 エラーが発生し続けます。送信しようとしているファイルは 21kb で、php.ini ファイルを確認しました。誰かが何が悪いのか教えてもらえますか?

HTTPリクエストに直接影響を与えるコードは次のとおりです。

    <?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Class for creating test cases to be sent 
 * into TestRail
 * @author Banderson
 */
class testCase {

    /*Function to get the data for each individual test case*/
    function getTestCase($row, $highestColIndex, $PHPobjWorksheet){

            echo "<br />";
            for($col=0;$col<=$highestColIndex;++$col){
                $v=$PHPobjWorksheet->getCellByColumnAndRow($col,$row)->getValue();
                $cellValue[]=$v;



        }

    return $cellValue;

    }


    /*Function to set the data for each individual test case*/
    function setTestCase($cellValue){
                $case[]=array();
                $case['title'] = $cellValue[0];
                echo $case['title']. "<- Title"."<br/>";
                $case['type'] = $cellValue[1];
                echo $case['type']. "<- Type"."<br/>";
                $case['priority'] = $cellValue[2];
                echo $case['priority']. "<- Priority"."<br/>";


                /*$case['estimate'] = $cellValue[3];
                echo $case['estimate']. "<- Estimate"."<br/>";
                $case['milestone'] = $cellValue[4];
                echo $case['milestone']. "<- MileStone"."<br/>";
                $case['refs'] = $cellValue[5];
                echo $case['refs']. "<- Custom Refs"."<br/>";
                $case['precon'] = $cellValue[6];
                echo $case['precon']. "<- Custom Precondition"."<br/>";
                $case['steps'] = $cellValue[7];
                echo $case['steps']. "<- Custom Steps"."<br/>";
                $case['expectedresults'] = $cellValue[8];
                echo  $case['expectedresults']. "<- Expected Results"."<br/>";
                $case['testSuite'] = $cellValue[9];
                echo $case['testSuite']. "<- TestSuite"."<br/>";*/


                $caseData=array(

                    'Title'=> $case['title'],
                    'Type'=> $case['type'],
                    'Priority'=> $case['priority'],
                    'key'=> "246810",


                );

                return $caseData;


    }

    function sendTestCase($caseArgs){
        try{
            $ch = curl_init();
            //$sendData = http_build_query($caseArgs);

            $header=array();
            $header[]= "Accept: application/json";

            $header[]= "Host: localhost";
            $header[]= "Title=newTitle";
            $header[]= "key=2467810";



            curl_setopt($ch, CURLOPT_URL, 'http://localhost:8888/testrail/index.php?/miniapi/add_case/2');  
            curl_setopt($ch, CURLOPT_POSTFIELDS, $header);
            curl_setopt($ch, CURLOPT_POST, 1);



            curl_exec($ch);
            curl_close($ch);
        }
        catch (HttpException $ex){
            echo $ex."<-Exception";
 }


    }

}

?>

php.ini ファイルをインクルードしたかったのですが、大きすぎます。私はどんなアドバイスにもオープンです!前もって感謝します!

4

1 に答える 1

1

413 は「リクエスト エンティティが大きすぎます」です。HTTP ヘッダーを POSTFIELDS セクションに詰め込もうとしている理由はありますか? このサービスが投稿フィールドを想定していない場合 (たとえば、本文は 0 バイトである必要があります)、POSTFIELD を使用して「ヘッダー」を送信すると、間違いなくこれが無効になります。ヘッダーの場合は、CURLOPT_HTTPHEADER代わりに使用する必要があります

于 2012-05-14T02:41:42.473 に答える