View our GitHub

Please visit sails-docs on GitHub to view documentation on your mobile device.

Edit Page

req.acceptsCharset()

Returns whether this request (req) is able to handle a specified characterSet.

Usage

req.acceptsCharset(characterSet);

Details

Useful for advanced content negotiation where a client may or may not support certain character sets, such as unicode (utf-8.) This method determines whether or not a request has specified the given characterSet as "acceptable" its Accept-Charset header (see RFC-2616.)

Example

If a request is sent with a "Accept-Charset: utf-8" header:

req.acceptsCharset('utf-8');
// -> true

Notes

  • See the accepts module for the finer details of the header parsing algorithm used in Sails/Express/Koa/Connect.

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails-docs repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.

Reference

We wrote a book!

Get early access to the book
with promotion code: mcneildoc

Get the Book