diff options
| author | Adnan Maolood <[email protected]> | 2021-02-14 23:33:16 -0500 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2021-02-14 23:33:18 -0500 |
| commit | 92e7a309c691b803a5c6665058d712d7659fcc57 (patch) | |
| tree | 2e73040aa19e4bdc1eefda42d9acb8d6cba09315 /request.go | |
| parent | fs: Refactor (diff) | |
| download | go-gemini-92e7a309c691b803a5c6665058d712d7659fcc57.tar.xz go-gemini-92e7a309c691b803a5c6665058d712d7659fcc57.zip | |
Tweak returned error for requests that are too long
Return ErrInvalidRequest instead of ErrInvalidURL in Request.Write.
Diffstat (limited to 'request.go')
| -rw-r--r-- | request.go | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -118,11 +118,14 @@ func ReadRequest(r io.Reader) (*Request, error) { // Write writes a Gemini request in wire format. // This method consults the request URL only. func (r *Request) Write(w *bufio.Writer) error { - url := r.URL.String() - // User is invalid - if r.URL.User != nil || len(url) > 1024 { + if r.URL.User != nil { + // User is not allowed return ErrInvalidURL } + url := r.URL.String() + if len(url) > 1024 { + return ErrInvalidRequest + } if _, err := w.WriteString(url); err != nil { return err } |