[http-server-javascript] Honor Accept
header
#5501
Labels
design:needed
A design request has been raised that needs a proposal
emitter:service:js
feature
New feature or request
triaged:core
Milestone
When the client sends an
Accept
header, the server generator should validate that it is sending a response with the given content-type before it responds (or that it can send such a content type).Accept-Encoding should also be validated, but that is of lesser value than Accept in this age of UTF-8 everywhere.
Accept
may also be required when the endpoint may return a data type with multiple serialization formats (e.g.@header contentType: "application/json" | "application/xml"
, but the JS server generator does not currently support this kind of dynamic serialization/deserialization based on actual content type.There are interesting cases to consider (as always):
In the above case, the service implementation can decide to return one type or the other, and they may be nonoverlapping, so the service implementation logic needs to know what, if anything, the client provided in the
Accept
header in order to choose which type to return.The service implementation can access this information through
HttpContext#request
today, but it might be worth making a first-class property ofHttpContext
if the router/binding implementation has to read and process it anyway.The text was updated successfully, but these errors were encountered: