2
votes

RFC 2616

10.2.2 201 Created

The response SHOULD include an entity containing a list of resource characteristics and location(s) from which the user or user agent can choose the one most appropriate. The entity format is specified by the media type given in the Content-Type header field.

If I make a request to create an image/png

POST /my/images HTTP/1.1
Content-Type: image/png
...

Should the entity of the response be a "list of resource characteristics and location(s)" formatted as a PNG?

Formatting a list of characteristics and locations as a PNG seems very wrong. Am I reading the HTTP standard correctly?

2

2 Answers

2
votes

a) You are reading the wrong document. What's relevant is RFC 7231.

b) From http://greenbytes.de/tech/webdav/rfc7231.html#status.201:

"6.3.2 201 Created

The 201 (Created) status code indicates that the request has been fulfilled and has resulted in one or more new resources being created. The primary resource created by the request is identified by either a Location header field in the response or, if no Location field is received, by the effective request URI.

The 201 response payload typically describes and links to the resource(s) created. See Section 7.2 for a discussion of the meaning and purpose of validator header fields, such as ETag and Last-Modified, in a 201 response."

So the special mention of Content-Type has been removed; it has the same meaning in all HTTP messages.

1
votes

To me it sounds like the Content-Type header on the response should be the content type of the body for the 201 response.

The Content-Type header is valid for both the request and response, and in both cases refers to the content type of the entity of the message. I agree that the spec could have been more clear about which message the Content-Type needed to be.