marijnh / Eloquent-JavaScript

The sources for the Eloquent JavaScript book
https://eloquentjavascript.net
3.01k stars 795 forks source link

Ch. 18, Exercise "Content negotiation" #425

Closed mhinz closed 6 years ago

mhinz commented 6 years ago

The last paragraph says:

Finally, try asking for the media type application/rainbows+unicorns and see what happens.

I get a 406.

I expected something funny, but either I'm doing something wrong or something is misconfigured on the server.

Did:

fetch("author", {headers: {Accept: "application/rainbows+unicorns"}})
  .then(resp => resp.text())
  .then(console.log);

Got:

<html>
<head><title>406 Not Acceptable</title></head>
<body bgcolor="white">
<center><h1>406 Not Acceptable</h1></center>
<hr><center>nginx/1.12.2</center>
</body>
</html>
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
<!-- a padding to disable MSIE and Chrome friendly error page -->
marijnh commented 6 years ago

Right, that phrasing may set the wrong expectations. I've updated it to talk about the status code