How can I force a 504
error in Chrome?
我如何在Chrome中强制504错误?
We have a node app that we occasionally get a 504
error from and I wanted do some error handling for 504
errors.
我们有一个节点应用我们偶尔会收到504个错误我想对504个错误做一些错误处理。
1 个解决方案
#1
3
Copy this into a file called server.js then run node server.js
. If you visit http://localhost:8080
you will be thrown a 504 error.
将其复制到一个名为server的文件中。然后运行node server.js。如果访问http://localhost:8080,将会抛出一个504错误。
var http = require('http');
var fs = require('fs');
http.createServer(function (req, res) {
console.log("Sending 504 error to client");
res.writeHead(504, {'Content-Type': 'text/plain'});
res.end();
}).listen(8080);
console.log("Server started on port 8080");
#1
3
Copy this into a file called server.js then run node server.js
. If you visit http://localhost:8080
you will be thrown a 504 error.
将其复制到一个名为server的文件中。然后运行node server.js。如果访问http://localhost:8080,将会抛出一个504错误。
var http = require('http');
var fs = require('fs');
http.createServer(function (req, res) {
console.log("Sending 504 error to client");
res.writeHead(504, {'Content-Type': 'text/plain'});
res.end();
}).listen(8080);
console.log("Server started on port 8080");