react-native/RNTester/js/http_test_server.js

36 lines
866 B
JavaScript
Raw Normal View History

#!/usr/bin/env node
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
*/
'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.
`);
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
* found when Flow v0.54 was deployed. To see the error delete this comment and
* run Flow. */
const connect = require('connect');
const http = require('http');
const app = connect();
app.use(function(req, res) {
console.log('received request');
RNTester http_server send cookie fix Summary: Signed-off-by: Evan J Brunner <ej3@appitto.me> <!-- Thank you for sending the PR! We appreciate you spending the time to work on these changes. Help us understand your motivation by explaining why you decided to make this change. You can learn more about contributing to React Native here: http://facebook.github.io/react-native/docs/contributing.html Happy contributing! --> Motivation can be found in #17899 This `RNTester/js/http_test_server.js` is part of a internal websocket test suite / devtool. Can be tested with `curl -D - localhost:5556` observing that the `Set-Cookie: wstest=OK; Path=\` header is present, and the service throws no exceptions.. etc [INTERNAL][MINOR][./RNTester/js/http_test_server.js] - fixed set cookie with connect framework <!-- Help reviewers and the release process by writing your own release notes **INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.** CATEGORY [----------] TYPE [ CLI ] [-------------] LOCATION [ DOCS ] [ BREAKING ] [-------------] [ GENERAL ] [ BUGFIX ] [-{Component}-] [ INTERNAL ] [ ENHANCEMENT ] [ {File} ] [ IOS ] [ FEATURE ] [ {Directory} ] |-----------| [ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} | [----------] [-------------] [-------------] |-----------| [CATEGORY] [TYPE] [LOCATION] - MESSAGE EXAMPLES: [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see --> Closes https://github.com/facebook/react-native/pull/17900 Differential Revision: D6977087 Pulled By: hramos fbshipit-source-id: af6205343fccf69c57e0c26a85a5b04d61288a23
2018-02-13 18:41:29 +00:00
res.setHeader('Set-Cookie', ['wstest=OK; Path=/']);
res.end('Cookie has been set!\n');
});
http.createServer(app).listen(5556);