Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[http-server-javascript] Honor Accept header #5501

Open
witemple-msft opened this issue Jan 6, 2025 · 0 comments
Open

[http-server-javascript] Honor Accept header #5501

witemple-msft opened this issue Jan 6, 2025 · 0 comments
Labels
design:needed A design request has been raised that needs a proposal emitter:service:js feature New feature or request triaged:core
Milestone

Comments

@witemple-msft
Copy link
Member

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):

op foo(): { @header contentType: "application/json", ...} | { @header contentType: "application/xml" }

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 of HttpContext if the router/binding implementation has to read and process it anyway.

@markcowl markcowl added emitter:service:js feature New feature or request labels Jan 7, 2025
@markcowl markcowl added the design:needed A design request has been raised that needs a proposal label Jan 8, 2025
@markcowl markcowl added this to the Backlog milestone Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design:needed A design request has been raised that needs a proposal emitter:service:js feature New feature or request triaged:core
Projects
None yet
Development

No branches or pull requests

2 participants