request-test
a Sails v1 application
Related with: balderdashy/sails#5305
Problem:
- io.socket always returns defaultLocale instead of browser language
How to reproduce this problem:
- look what's your prefered browser language and then setup some another in i18n.js as defaultLocale (not identical with your browser language)
Exception:
- both values in first two rows should be the same because they are obtained from the same page - but they are different if
defaultLocale
is not same as preferedAccept-Language
:/
Changes in code:
- /api/controllerss/http.js
- /api/controllerss/ajax.js
- /config/i18n.js
- /config/routes.js
- /views/layouts/layout.ejs
- /views/pages/homepage.ejs
- /assets/dependencies/jquery.min.js
- /assets/images/czech-results.png
Life cycle of app:
-
http get '/'
- returns ejs value on HP via action:exits: { success: { viewTemplatePath: 'pages/homepage' }, }, fn: async function (inputs, exits) { return exits.success( { lang: this.req.getLocale() } ); }
-
$(document).ready(function(){ io.socket.post('/', {}, function(ret){ $('#socket-response').html("'" + ret.lang + "'"); }); });
- returns json via action:
exits: { succsess: { statusCode: 200, responseType: 'jsonResponse' } }, fn: async function (inputs, exits) { return exits.success({lang: this.req.getLocale()}); }
This app was originally generated on Thu May 09 2019 07:40:44 GMT+0200 (Central Europe Daylight Time) using Sails v1.1.0.