我正在通过cURL发送一个超文本传输协议请求,我一直收到这个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文件,但是这个文件太大了。我愿意接受任何建议!提前谢谢你!
发布于 2012-05-14 10:41:42
413是“请求实体太大”。你想把HTTP头塞进POSTFIELDS部分有什么原因吗?如果此服务不需要任何post字段(例如,body应该是0字节),那么使用POSTFIELD发送您的“头”肯定会将其设置为关闭。对于headeres,您应该改用CURLOPT_HTTPHEADER
https://stackoverflow.com/questions/10576914
复制相似问题