Update comments
This commit is contained in:
parent
57a124a8b9
commit
0cb8083ce3
|
@ -321,7 +321,6 @@ func (s *Server) Serve(l net.Listener) error {
|
||||||
// ResponseWriter is used by a Gemini handler to construct a Gemini response.
|
// ResponseWriter is used by a Gemini handler to construct a Gemini response.
|
||||||
type ResponseWriter struct {
|
type ResponseWriter struct {
|
||||||
w *bufio.Writer
|
w *bufio.Writer
|
||||||
wroteHeader bool
|
|
||||||
bodyAllowed bool
|
bodyAllowed bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,15 +368,15 @@ func (s *Server) respond(conn net.Conn) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Trim carriage return
|
|
||||||
rawurl = rawurl[:len(rawurl)-1]
|
|
||||||
// Read terminating line feed
|
// Read terminating line feed
|
||||||
if b, err := r.ReadByte(); err != nil {
|
if b, err := r.ReadByte(); err != nil {
|
||||||
return
|
return
|
||||||
} else if b != '\n' {
|
} else if b != '\n' {
|
||||||
rw.WriteHeader(StatusBadRequest, "Bad request")
|
rw.WriteHeader(StatusBadRequest, "Bad request")
|
||||||
}
|
}
|
||||||
|
// Trim carriage return
|
||||||
|
rawurl = rawurl[:len(rawurl)-1]
|
||||||
|
// Ensure URL is valid
|
||||||
if len(rawurl) > 1024 {
|
if len(rawurl) > 1024 {
|
||||||
rw.WriteHeader(StatusBadRequest, "Requested URL exceeds 1024 bytes")
|
rw.WriteHeader(StatusBadRequest, "Requested URL exceeds 1024 bytes")
|
||||||
} else if url, err := url.Parse(rawurl); err != nil || url.User != nil {
|
} else if url, err := url.Parse(rawurl); err != nil || url.User != nil {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user