fix dead loop while network error (#77)
This commit is contained in:
@@ -7,7 +7,6 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -27,10 +26,8 @@ func (stream *CompletionStream) Recv() (response CompletionResponse, err error)
|
|||||||
waitForData:
|
waitForData:
|
||||||
line, err := stream.reader.ReadBytes('\n')
|
line, err := stream.reader.ReadBytes('\n')
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if errors.Is(err, io.EOF) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
var headerData = []byte("data: ")
|
var headerData = []byte("data: ")
|
||||||
line = bytes.TrimSpace(line)
|
line = bytes.TrimSpace(line)
|
||||||
|
|||||||
Reference in New Issue
Block a user