We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
var http = require('http'); var server = http.createServer(); var log = function (str) { console.log('##' + Date.now() + '##'); console.log(str); } server.on('request', function (req, res) { // req读入流 res写出流 req.on('data', function (chunk) { log('server-request-data-' + chunk.toString()); }).on('end', function () { log('server-request-end'); res.writeContinue(); res.end(); }); }).on('connection', function (socket) { // socket 双工流 socket.on('data', function (chunk) { log('server-connection-data-' + chunk.toString()); }); socket.on('end', function () { log('server-connection-end'); }); // socket.write('server socket'); // socket.end('server socket end'); }).listen(9999, function () { var opt = { protocol: 'http:', hostname: '127.0.0.1', port: 9999, method: 'POST', }; var client = http.request(opt); client.on('response', function (res) { // res 可读流 res.on('data', function (chunk) { log('client-response-data-' + chunk.toString()); }); res.on('end', function () { log('client-response-end'); }); }).on('socket', function (socket) { // socket duplux流,可读可写 socket.on('data', function (chunk) { log('client-socket-data-' + chunk.toString()); }); socket.on('end', function () { log('client-socket-end'); }); // socket.write('client socket'); // socket.end('client socket end'); }); client.write('client write'); client.end('client write end'); });
##1551610895924## server-connection-data-POST / HTTP/1.1 Host: 127.0.0.1:9999 Connection: close Transfer-Encoding: chunked c client write 10 client write end 0 ##1551610895925## server-request-data-client write ##1551610895926## server-request-data-client write end ##1551610895926## server-request-end ##1551610895931## client-socket-data-HTTP/1.1 100 Continue HTTP/1.1 200 OK Date: Sun, 03 Mar 2019 11:01:35 GMT Connection: close Content-Length: 0 ##1551610895932## client-response-end
headers: { 'Connection': 'Upgrade', 'Upgrade': 'websocket' }
headers: { 'Expect': '100-continue' }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
读写流备注
= server端通过connection事件可以获取数据通信服务端socket,
connect代理触发
upgrade触发
continue触发
The text was updated successfully, but these errors were encountered: