summaryrefslogtreecommitdiffstats
path: root/server.go
diff options
context:
space:
mode:
authorclsr <clsr@clsr.net>2017-08-22 14:33:57 +0200
committerclsr <clsr@clsr.net>2017-08-22 14:33:57 +0200
commitba217ddeef9c6cd502a6f150bf59cf3ce329cc61 (patch)
treee1a6f6bbe3f6ba9dda9dd7388bedc015dc6dfa63 /server.go
parentda77deba78c8a7447b4a38324d2422a5df293b26 (diff)
downloadcnp-go-ba217ddeef9c6cd502a6f150bf59cf3ce329cc61.tar.gz
cnp-go-ba217ddeef9c6cd502a6f150bf59cf3ce329cc61.zip
Check errors before accessing possibly-nil request fieldsv0.1.1
Diffstat (limited to 'server.go')
-rw-r--r--server.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/server.go b/server.go
index 3413923..4320f41 100644
--- a/server.go
+++ b/server.go
@@ -122,7 +122,6 @@ func (srv *Server) HandleConn(conn net.Conn) {
}()
req, err := ParseRequest(conn)
- req.Body = io.LimitReader(req.Body, req.Length())
if err != nil {
if e, ok := err.(Error); ok {
resp, _ := NewResponse(IntentError, nil)
@@ -133,6 +132,8 @@ func (srv *Server) HandleConn(conn net.Conn) {
panic(err)
}
+ req.Body = io.LimitReader(req.Body, req.Length())
+
if srv.Validate {
err = req.Validate()
if err != nil {