406 Недопустимая ошибка для типов пантомимы yang в методе GET в Apache MacOS Catalina - PullRequest
0 голосов
/ 12 февраля 2020

У меня есть URL, который получает GET-ответ от сервера: http://localhost: 8080 / api / config / sae-site? Deep с использованием REST. Заголовки запроса:

Accept: application/vnd.yang.collection+xml
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Access-Control-Allow-Origin: *
Appkey: cnRqY3J0amNydGpjc2Vqc3J0amNydGpjanJqc2pyc2Jzbmp1Y2FybGp0anRzZWp0cnVqa3J0am9qbHNhamxzaQ==
Connection: keep-alive
Host: localhost
Referer: http://localhost/
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin

Это ответ, который я получаю:

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>406 Not Acceptable</title>
</head><body>
<h1>Not Acceptable</h1>
<p>An appropriate representation of the requested resource could not be found on this server.</p>
Available variants:
<ul>
<li><a href="api.php">api.php</a> , type application/x-httpd-php</li>
</ul>
</body></html>

Я пробовал много решений в Интернете, но ни одно из них не работает для меня. mod_security также не работает. Если я удаляю заголовок Accept и по умолчанию принимаю его, он работает нормально, но всегда получает только данные JSON.

Это мой прокси-код php для обработки заголовков Accept:

if($methodType == RESTMethodType::RMT_POST || $methodType == RESTMethodType::RMT_PUT || $methodType == RESTMethodType::RMT_PATCH) {
                $headers[] = "Accept: application/vnd.yang.datastore+xml, application/vnd.yang.collection+xml, application/vnd.yang.data+xml, " . $this->_reqHeader['Accept'];
            } else {
                $headers[] = "Accept: " . $this->_reqHeader['Accept'];
            }

Это apache журналы:

tail /var/log/apache2/error_log
[Tue Feb 11 14:51:26.375045 2020] [negotiation:error] [pid 21083] [client ::1:61341] AH00690: no acceptable variant: /Users/abc/Sites/gwapi/api, referer: http://localhost/
[Tue Feb 11 14:51:26.378865 2020] [negotiation:error] [pid 21083] [client ::1:61341] AH00690: no acceptable variant: /Users/abc/Sites/gwapi/api, referer: http://localhost/
[Tue Feb 11 14:51:26.378277 2020] [negotiation:error] [pid 21082] [client ::1:61343] AH00690: no acceptable variant: /Users/abc/Sites/gwapi/api, referer: http://localhost/
[Tue Feb 11 14:51:26.379557 2020] [negotiation:error] [pid 21056] [client ::1:61344] AH00690: no acceptable variant: /Users/abc/Sites/gwapi/api, referer: http://localhost/
[Tue Feb 11 14:51:26.379825 2020] [negotiation:error] [pid 21064] [client ::1:61345] AH00690: no acceptable variant: /Users/abc/Sites/gwapi/api, referer: http://localhost/
[Tue Feb 11 14:51:26.384473 2020] [negotiation:error] [pid 21082] [client ::1:61343] AH00690: no acceptable variant: /Users/abc/Sites/gwapi/api, referer: http://localhost/
[Tue Feb 11 14:51:26.391030 2020] [negotiation:error] [pid 21056] [client ::1:61344] AH00690: no acceptable variant: /Users/abc/Sites/gwapi/api, referer: http://localhost/
[Tue Feb 11 14:51:26.396408 2020] [negotiation:error] [pid 21064] [client ::1:61345] AH00690: no acceptable variant: /Users/abc/Sites/gwapi/api, referer: http://localhost/
[Tue Feb 11 14:51:26.410061 2020] [negotiation:error] [pid 21082] [client ::1:61343] AH00690: no acceptable variant: /Users/abc/Sites/gwapi/api, referer: http://localhost/
[Tue Feb 11 14:51:26.413981 2020] [negotiation:error] [pid 21056] [client ::1:61344] AH00690: no acceptable variant: /Users/abc/Sites/gwapi/api, referer: http://localhost/

Как это исправить? Любая помощь очень ценится.

...