diff options
author | clsr <clsr@clsr.net> | 2017-09-01 16:11:42 +0200 |
---|---|---|
committer | clsr <clsr@clsr.net> | 2017-09-01 16:11:42 +0200 |
commit | 7e1f90f27d876db67158ca4787420ec30c18f86b (patch) | |
tree | 4526e5924c926af4814968a49c2dd7875fdf0dd0 /common.go | |
parent | ee431f1e85a8ee7d3c6e069c8858c671da1c2acd (diff) | |
download | cnp-go-7e1f90f27d876db67158ca4787420ec30c18f86b.tar.gz cnp-go-7e1f90f27d876db67158ca4787420ec30c18f86b.zip |
Distinguish between response length=0 and no length parameter
Response.Length returns -1 when the parameter is not present and 0
when it's set to 0.
Response.SetLength will only unset the parameter when given -1.
Diffstat (limited to 'common.go')
-rw-r--r-- | common.go | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -30,10 +30,10 @@ func readLimitedLine(br *bufio.Reader, length int) ([]byte, error) { } } -func getInt(m *Message, param string) (int64, error) { +func getInt(m *Message, param string, fallback int64) (int64, error) { p := m.Param(param) if p == "" { - return 0, nil + return fallback, nil } n, err := strconv.ParseUint(p, 10, 63) if err != nil || (n != 0 && p[0] == '0') || (n == 0 && len(p) != 1) { |