fix: 增加replace方式,修复github readme引用图片打不开的问题
parent
72806825c0
commit
278ae695ca
|
@ -33,8 +33,8 @@ function registerProcessListener () {
|
|||
log.error('uncaughtException:', err)
|
||||
})
|
||||
|
||||
process.on('unhandledRejection', (reason, p) => {
|
||||
log.info('Unhandled Rejection at: Promise', p, 'reason:', reason)
|
||||
process.on('unhandledRejection', (err, p) => {
|
||||
log.info('Unhandled Rejection at: Promise', p, 'err:', err)
|
||||
// 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('代理请求超时', rOptions.protocol, rOptions.hostname, rOptions.path, (end - start) + 'ms')
|
||||
// reject(new Error(`${rOptions.host}:${rOptions.port}, 代理请求超时`))
|
||||
proxyReq.end()
|
||||
proxyReq.destroy()
|
||||
res.writeHead(408)
|
||||
res.write('DevSidecar Warning:\n\n 请求超时')
|
||||
res.end()
|
||||
const error = new Error(`${rOptions.host}:${rOptions.port}, 代理请求超时`)
|
||||
error.status = 408
|
||||
reject(error)
|
||||
})
|
||||
|
||||
proxyReq.on('error', (e) => {
|
||||
|
@ -198,7 +197,8 @@ module.exports = function createRequestHandler (requestInterceptor, responseInte
|
|||
},
|
||||
(e) => {
|
||||
if (!res.finished) {
|
||||
res.writeHead(500)
|
||||
const status = e.status || 500
|
||||
res.writeHead(status)
|
||||
res.write(`DevSidecar Warning:\n\n ${e.toString()}`)
|
||||
res.end()
|
||||
log.error('request error', e.message)
|
||||
|
|
|
@ -65,7 +65,7 @@ module.exports = {
|
|||
})
|
||||
server.on('request', (req, res) => {
|
||||
const ssl = false
|
||||
// log.info('request,', req.url, req.port, req.host)
|
||||
// log.info('request,', req.hostname)
|
||||
requestHandler(req, res, ssl)
|
||||
})
|
||||
// tunneling for https
|
||||
|
@ -78,6 +78,10 @@ module.exports = {
|
|||
const ssl = false
|
||||
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) {
|
||||
callback(server)
|
||||
|
|
Loading…
Reference in New Issue