Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Niggling conneg

Sean Cribbs
September 27, 2014

Niggling conneg

How should web servers respond when it they are unable to satisfy the client's representational constraints? The HTTP RFCs are a little vague on the matter. These are some possibilities of what some "correct" responses might be.

This 5-in-5 talk came from discussions I had with Darrel Miller, Mike Amundsen and Larry Staton, Jr. at RESTfest 2014.

Sean Cribbs

September 27, 2014

Transcript

9 slides
  1. 300 Multiple Choices If the server has a preferred choice,

    the server SHOULD generate a Location header !eld containing a preferred choice's URI reference. The user agent MAY use the Location !eld value for automatic redirection. RFC 7231
  2. text/uri-list 300 Multiple Choices HTTP/1.1 Content-Type: text/uri-list Vary: Accept http://myserver/foo.pdf

    http://myserver/foo.html http://myserver/foo.txt http://myserver/foo.jpeg # http://myserver/foo.json
  3. Link relations/types 300 Multiple Choices HTTP/1.1 Content-Type: text/html Vary: Accept

    <html> <head> <link rel=“alternate” type=“application/pdf” href=“...”> <link rel=“alternate” type=“text/html” href=“...”> </head> <body><!-- links for humans too! --> </body> </html>
  4. Response Headers 300 Multiple Choices HTTP/1.1 Vary: Accept Link: </foo.pdf>;rel=“alternate”;type=“application/

    pdf”, ... ------------------------------------------------ 300 Multiple Choices HTTP/1.1 Vary: Accept Provides: application/pdf, text/html, image/jpeg ------------------------------------------------ RFC 2295 also defined “Alternates” header.

More Decks by Sean Cribbs

Other Decks in Programming