Subject: "Accept" on 415 responses?

From: Julian Reschke <[email-masked]>
Date: Mon, 12 Dec 2011 22:21:16 +0100

Hi there,

see

<http://stackoverflow.com/questions/3343165/specify-supported-media-types-when-sending-415-unsupported-media-type>

Should we specify what it means to return an Accept header field in an 
HTTP *response*?

Best regards, Julian

---

From: Amos Jeffries <[email-masked]>
Date: Tue, 13 Dec 2011 12:33:36 +1300

On Mon, 12 Dec 2011 22:21:16 +0100, Julian Reschke wrote:
> Should we specify what it means to return an Accept header field in
> an HTTP *response*?
>
> Best regards, Julian

 Having something to identify the valid set is needed. Makes sense that 
 it should be the existing Accept: header.

 AYJ

---

From: mike amundsen <[email-masked]>
Date: Mon, 12 Dec 2011 16:56:25 -0500

Yes, I think this could be helpful.

I adopted a similar pattern for some internal work a while back that
addressed this problem[1]:

In a nutshell, I added this to options:

-- Typical call to OPTIONS for this URL
REQUEST: **************
OPTIONS /xcs/ugdata/ HTTP/1.1
content-type:text/plain
Host: localhost
Accept: */*

RESPONSE: **************
HTTP/1.1 200 OK
Allow: DELETE,GET,HEAD,OPTIONS,POST,PUT
X-Accept-Types: text/html,text/xml,application/json
X-Content-Types: text/xml,application/x-www-form-urlencoded,application/json

In the running implementation I created, this kind of information is
also returned for 405, 406, and 415

And, yes, the "X-" is earns a sad face<g>.

[1] http://www.amundsen.com/blog/archives/716

mca
http://amundsen.com/blog/
http://twitter.com@mamund
http://mamund.com/foaf.rdf#me

On Mon, Dec 12, 2011 at 16:21, Julian Reschke <[email-masked]> wrote:
> Should we specify what it means to return an Accept header field in an HTTP *response*?
>
> Best regards, Julian
>

---

From: Amos Jeffries <[email-masked]>
Date: Tue, 13 Dec 2011 17:19:25 +1300

> X-Content-Types: text/xml,application/x-www-form-urlencoded,application/json

You seem to have a problem: the two headers are advertising two unique 
sets of mime types as being accepted from the client by this server.
Surely it should at least be advertising a consistent set.

AYJ

---

From: mike amundsen <[email-masked]>
Date: Mon, 12 Dec 2011 23:26:59 -0500

Amos:

in the example i attached:

X-Accept-Types: text/html,text/xml,application/json
is what clients can use when negotiating responses from servers

X-Content-Types: text/xml,application/x-www-form-urlencoded,application/json
is what clients can use when constructing bodies that will be sent to servers

There might be better names for these two cases.

mca

On Mon, Dec 12, 2011 at 23:19, Amos Jeffries <[email-masked]> wrote:
>> X-Content-Types:
>> text/xml,application/x-www-form-urlencoded,application/json
>
>
> You seem to have a problem: the two headers are advertising two unique sets
> of mime types as being accepted from the client by this server.

---

From: Amos Jeffries <[email-masked]>
Date: Tue, 13 Dec 2011 18:10:33 +1300

> There might be better names for these two cases.

Thanks. Yes different names would be better to clarify that for the 
casual traffic observer.

Since OPTIONS is all about the server resource I guessed from the chosen 
names that Content-Types was types emitted by the server in Content-Type 
header, and "Accept-Types" being the values it understood in the Accept 
header. Which should be the same set.

Since this proposal for opening Accept to mean what your X-Content-Types 
does, are you in a position to reverse the definitions easily?
eg by changing X-Content-Types => Accept, and X-Accept-Types => 
Content-Types (with no "X-").  I might join you and make a second 
RESTful implementation along the same lines if this convention passes 
acceptance of the experts here.

AYJ

---

From: Willy Tarreau <[email-masked]>
Date: Tue, 13 Dec 2011 07:14:10 +0100

Hi Julian,

> Should we specify what it means to return an Accept header field in an 

Yes, I think that for this use case it makes sense.

Regards,
Willy

---

From: Thomas Fossati <[email-masked]>
Date: Tue, 13 Dec 2011 14:37:08 +0100

Hi Julian,

> Should we specify what it means to return an Accept header field in an HTTP *response*?

that would be very helpful for handling transparent media type translations (e.g. EXI to XML) by an HTTP/CoAP proxy.

What requirement level do you think is needed here ?