44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* The examples provided by Facebook are for non-commercial testing and
|
|
* evaluation purposes only.
|
|
*
|
|
* Facebook reserves all rights not expressly granted.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
|
|
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
|
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*
|
|
* @flow
|
|
*/
|
|
'use strict';
|
|
|
|
/* eslint-env node */
|
|
|
|
console.log(`\
|
|
Test server for WebSocketExample
|
|
|
|
This will set a cookie named "wstest" on the response of any incoming request.
|
|
`);
|
|
|
|
const connect = require('connect');
|
|
const http = require('http');
|
|
|
|
const app = connect();
|
|
|
|
app.use(function(req, res) {
|
|
console.log('received request');
|
|
const cookieOptions = {
|
|
//httpOnly: true, // the cookie is not accessible by the user (javascript,...)
|
|
secure: false, // allow HTTP
|
|
};
|
|
res.cookie('wstest', 'OK', cookieOptions);
|
|
res.end('Cookie has been set!\n');
|
|
});
|
|
|
|
http.createServer(app).listen(5556);
|