fix: 增加replace方式,修复github readme引用图片打不开的问题
parent
72806825c0
commit
278ae695ca
|
@ -33,8 +33,8 @@ function registerProcessListener () {
|
||||||
log.error('uncaughtException:', err)
|
log.error('uncaughtException:', err)
|
||||||
})
|
})
|
||||||
|
|
||||||
process.on('unhandledRejection', (reason, p) => {
|
process.on('unhandledRejection', (err, p) => {
|
||||||
log.info('Unhandled Rejection at: Promise', p, 'reason:', reason)
|
log.info('Unhandled Rejection at: Promise', p, 'err:', err)
|
||||||
// application specific logging, throwing an error, or other logic here
|
// application specific logging, throwing an error, or other logic here
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,12 +96,11 @@ module.exports = function createRequestHandler (requestInterceptor, responseInte
|
||||||
log.error('记录ip失败次数,用于优选ip:', hostname, ip)
|
log.error('记录ip失败次数,用于优选ip:', hostname, ip)
|
||||||
}
|
}
|
||||||
log.error('代理请求超时', rOptions.protocol, rOptions.hostname, rOptions.path, (end - start) + 'ms')
|
log.error('代理请求超时', rOptions.protocol, rOptions.hostname, rOptions.path, (end - start) + 'ms')
|
||||||
// reject(new Error(`${rOptions.host}:${rOptions.port}, 代理请求超时`))
|
|
||||||
proxyReq.end()
|
proxyReq.end()
|
||||||
proxyReq.destroy()
|
proxyReq.destroy()
|
||||||
res.writeHead(408)
|
const error = new Error(`${rOptions.host}:${rOptions.port}, 代理请求超时`)
|
||||||
res.write('DevSidecar Warning:\n\n 请求超时')
|
error.status = 408
|
||||||
res.end()
|
reject(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
proxyReq.on('error', (e) => {
|
proxyReq.on('error', (e) => {
|
||||||
|
@ -198,7 +197,8 @@ module.exports = function createRequestHandler (requestInterceptor, responseInte
|
||||||
},
|
},
|
||||||
(e) => {
|
(e) => {
|
||||||
if (!res.finished) {
|
if (!res.finished) {
|
||||||
res.writeHead(500)
|
const status = e.status || 500
|
||||||
|
res.writeHead(status)
|
||||||
res.write(`DevSidecar Warning:\n\n ${e.toString()}`)
|
res.write(`DevSidecar Warning:\n\n ${e.toString()}`)
|
||||||
res.end()
|
res.end()
|
||||||
log.error('request error', e.message)
|
log.error('request error', e.message)
|
||||||
|
|
|
@ -65,7 +65,7 @@ module.exports = {
|
||||||
})
|
})
|
||||||
server.on('request', (req, res) => {
|
server.on('request', (req, res) => {
|
||||||
const ssl = false
|
const ssl = false
|
||||||
// log.info('request,', req.url, req.port, req.host)
|
// log.info('request,', req.hostname)
|
||||||
requestHandler(req, res, ssl)
|
requestHandler(req, res, ssl)
|
||||||
})
|
})
|
||||||
// tunneling for https
|
// tunneling for https
|
||||||
|
@ -78,6 +78,10 @@ module.exports = {
|
||||||
const ssl = false
|
const ssl = false
|
||||||
upgradeHandler(req, socket, head, ssl)
|
upgradeHandler(req, socket, head, ssl)
|
||||||
})
|
})
|
||||||
|
server.on('clientError', (err, socket) => {
|
||||||
|
log.error('client error', err)
|
||||||
|
socket.end('HTTP/1.1 400 Bad Request\r\n\r\n')
|
||||||
|
})
|
||||||
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(server)
|
callback(server)
|
||||||
|
|
Loading…
Reference in New Issue