mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-17 05:03:52 -07:00
@@ -32,6 +32,7 @@ const (
|
|||||||
httpUnauthorized = "HTTP/1.1 401 Unauthorized" + crlf
|
httpUnauthorized = "HTTP/1.1 401 Unauthorized" + crlf
|
||||||
httpUnavailable = "HTTP/1.1 503 Service Unavailable" + crlf
|
httpUnavailable = "HTTP/1.1 503 Service Unavailable" + crlf
|
||||||
httpReadTimeout = 10 * time.Second
|
httpReadTimeout = 10 * time.Second
|
||||||
|
channelTimeout = 2 * time.Second
|
||||||
jsonContentType = "Content-Type: application/json" + crlf
|
jsonContentType = "Content-Type: application/json" + crlf
|
||||||
maxContentLength = 1024 * 1024
|
maxContentLength = 1024 * 1024
|
||||||
)
|
)
|
||||||
@@ -170,7 +171,7 @@ func (server *httpServer) handleHttpRequest(conn net.Conn) string {
|
|||||||
select {
|
select {
|
||||||
case response := <-server.responseChannel:
|
case response := <-server.responseChannel:
|
||||||
return good(response)
|
return good(response)
|
||||||
case <-time.After(2 * time.Second):
|
case <-time.After(channelTimeout):
|
||||||
go func() {
|
go func() {
|
||||||
// Drain the channel
|
// Drain the channel
|
||||||
<-server.responseChannel
|
<-server.responseChannel
|
||||||
@@ -227,7 +228,11 @@ func (server *httpServer) handleHttpRequest(conn net.Conn) string {
|
|||||||
return bad("no action specified")
|
return bad("no action specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
server.actionChannel <- actions
|
select {
|
||||||
|
case server.actionChannel <- actions:
|
||||||
|
case <-time.After(channelTimeout):
|
||||||
|
return httpUnavailable + crlf
|
||||||
|
}
|
||||||
return httpOk + crlf
|
return httpOk + crlf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user