使用POST REST请求URI太长

时间:2018-07-06 13:12:48

标签: php rest post

我有以下PHP代码,可以用来访问POST方法REST Web服务:

$PJS = isset($_REQUEST['arrayFile']) ? $_REQUEST['arrayFile'] : array();
    foreach ($PJS as $PJ) {
        $ext    = explode('/', $PJ['type'])[1];
        $storeAttachmentResourceParams = array(
        'encodedFile'   => $PJ['content'],
        'resId'         => $resId,
        'data'          => json_encode(
                                array(
                                    array('column' => 'title', 'value' => 'PJ', 'type' => 'string'),
                                    array('column' => 'attachment_type', 'value' => 'simple_attachment', 'type' => 'string'),
                                    array('column' => 'status', 'value' => 'A_TRA', 'type' => 'string'),
                                  )
                            ),
        'collId'        => 'letterbox_coll',
        'collIdMaster'  => 'letterbox_coll',
        'table'         => 'res_attachments',
        'fileFormat'    => $ext
    );
        $storeAttachmentResource = Requests::post($cfg['url'] . '/attachments', array(), $storeAttachmentResourceParams, $options);

这段PHP代码是在wordpress PHP代码段下调用的,如下所示:

$url = 'https://XXXX.XXX.fr/interface/iface.php';
$options = array(
     'http' => array(
     'header' => "",
     'proxy'     => "tcp://192.168.X.X:3128",
     'timeout' => 100,
     'method' => 'POST',
     'content' => http_build_query($data)
     )
);
$context = stream_context_create($options);
$return = file_get_contents($url, false, $context);
$returnIface = json_decode($return);

我修改我的Apache2.conf如下所示,以添加LimitRequestLine:

AccessFileName .htaccess
LimitRequestLine 10000000
LimitRequestFieldSize 10000000

重新启动Apache2服务器,但在我的浏览器中仍然出现以下错误:

 Request-URI Too Long

The requested URL's length exceeds the capacity
limit for this server.



Apache/2.4.25 (Debian) Server at infosv47.sartrouville.lan Port 80


"
  ["headers"]=>
  object(Requests_Response_Headers)#23 (1) {
    ["data":protected]=>
    array(4) {
      ["date"]=>
      array(1) {
        [0]=>
        string(29) "Fri, 06 Jul 2018 13:03:25 GMT"
      }
      ["server"]=>
      array(1) {
        [0]=>
        string(22) "Apache/2.4.25 (Debian)"
      }
      ["content-length"]=>
      array(1) {
        [0]=>
        string(3) "339"
      }
      ["content-type"]=>
      array(1) {
        [0]=>
        string(29) "text/html; charset=iso-8859-1"
      }
    }
  }
  ["status_code"]=>
  int(414)
  ["protocol_version"]=>
  float(1.1)
  ["success"]=>
  bool(false)
  ["redirects"]=>
  int(0)
  ["url"]=>
  string(46) "http://10.10.XX.XX/cs_maarch/rest/attachments"
  ["history"]=>
  array(0) {
  }
  ["cookies"]=>
  object(Requests_Cookie_Jar)#20 (1) {
    ["cookies":protected]=>
    array(0) {
    }
  }
}

它在Debian 9之下

0 个答案:

没有答案