Quantcast
Channel: WampServer - WampServer English
Viewing all articles
Browse latest Browse all 3177

Status Code 406 using headers with [Accept: application/json] (no replies)

$
0
0
When I send a GET request to a.php using headers with [Accept: application/json], my server gives me 406.
If I remove [Accept: application/json] from headers, everything works well and gives me 200.
I have tried everything i googled, but nothing works.
How can the server accept requests with [Accept: application/json] and dealing it with php?


Request Headers:
GET a.php HTTP/1.1
Host: 127.0.0.1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/115.0
Accept: application/json
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: cross-site
Sec-Fetch-User: ?1
Pragma: no-cache
Cache-Control: no-cache



Response Headers:
HTTP/1.1 406 Not Acceptable
Date: Wed, 26 Jul 2023 15:28:33 GMT
Server: Apache
Alternates: {"a.php" 1 {type application/x-httpd-php} {length 104}}
Vary: negotiate
TCN: list
Content-Length: 353
Keep-Alive: timeout=60
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1




a.php:
<?php
header('Content-type: application/json');
$result[data] = 'yes';
echo json_encode($result);
?>




406 Page:
<!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 a.php could not be found on this server.</p>
Available variants:
<ul>
<li><a href="a.php">a.php</a> , type application/x-httpd-php</li>
</ul>
</body></html>

Viewing all articles
Browse latest Browse all 3177

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>