diff options
Diffstat (limited to 'gemini/request.go')
-rw-r--r-- | gemini/request.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/gemini/request.go b/gemini/request.go index ced7d0b..5220952 100644 --- a/gemini/request.go +++ b/gemini/request.go @@ -13,8 +13,15 @@ import ( var InvalidRequestLineEnding = errors.New("invalid request line ending") // ParseRequest parses a single gemini request from a reader. +// +// If the reader argument is a *bufio.Reader, it will only read a single line from it. func ParseRequest(rdr io.Reader) (*gus.Request, error) { - line, err := bufio.NewReader(rdr).ReadString('\n') + bufrdr, ok := rdr.(*bufio.Reader) + if !ok { + bufrdr = bufio.NewReader(rdr) + } + + line, err := bufrdr.ReadString('\n') if err != io.EOF && err != nil { return nil, err } |