使用REST,Request-URI太长

时间:2017-11-23 13:08:25

标签: php rest

我目前正在使用一些REST网络服务,而且我正面临一个问题。我有一个带PHP接口的服务器,从远程Wordpress收集表单信息。该接口与REST Web服务所在的另一台服务器进行通信。 在我的接口服务器中,我有以下功能,在REST中进行通信:

$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('http://192.168.10.97/rest/attachments', array(), $storeAttachmentResourceParams, $options);
            file_put_contents('/tmp/iface_debug.txt', print_r($storeAttachmentResource, true), FILE_APPEND);
        }

encodedFile是base64编码文件(image,pdf或docx)。当请求完成后,我的服务器界面会说这个(感谢file_puts_content):

Requests_Response Object
(
    [body] => <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>414 Request-URI Too Long</title>
</head><body>
<h1>Request-URI Too Long</h1>
<p>The requested URL's length exceeds the capacity
limit for this server.<br />
</p>
<hr>
<address>Apache/2.4.10 (Debian) Server at 127.0.1.1 Port 80</address>
</body></html>

    [raw] => HTTP/1.1 414 Request-URI Too Long
Date: Thu, 23 Nov 2017 13:04:26 GMT
Server: Apache/2.4.10 (Debian)
Content-Length: 323
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>414 Request-URI Too Long</title>
</head><body>
<h1>Request-URI Too Long</h1>
<p>The requested URL's length exceeds the capacity
limit for this server.<br />
</p>
<hr>
<address>Apache/2.4.10 (Debian) Server at 127.0.1.1 Port 80</address>
</body></html>

    [headers] => Requests_Response_Headers Object
        (
            [data:protected] => Array
                (
                    [date] => Array
                        (
                            [0] => Thu, 23 Nov 2017 13:04:26 GMT
                        )

                    [server] => Array
                        (
                            [0] => Apache/2.4.10 (Debian)
                        )

                    [content-length] => Array
                        (
                            [0] => 323
                        )

                    [content-type] => Array
                        (
                            [0] => text/html; charset=iso-8859-1
                        )

                )

        )

    [status_code] => 414
    [protocol_version] => 1.1
    [success] => 
    [redirects] => 0
    [url] => http://192.168.10.97/rest/attachments
    [history] => Array
        (
        )

    [cookies] => Requests_Cookie_Jar Object
        (
            [cookies:protected] => Array
                (
                )

        )

) 

我在Google上搜索了一下,发现像LimitRequestLine这样的参数可以修改为Apache,但是它没有用。

您对此问题有任何解决方案吗?

0 个答案:

没有答案