diff options
Diffstat (limited to 'response.go')
-rw-r--r-- | response.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/response.go b/response.go index 3ecb961..4c3f753 100644 --- a/response.go +++ b/response.go @@ -224,6 +224,26 @@ func (r *Response) SetSelect(selector, query string) error { return setSelect(&r.Message, "select", selector, query) } +// Length gets the length response parameter (or -1 if it's not set or invalid). +func (r *Response) Length() int64 { + n, err := getInt(&r.Message, "length", -1) + if err != nil { + return -1 + } + return n +} + +// SetLength sets the length response parameter to n. +// +// If negative, the parameter is unset. +func (r *Response) SetLength(n int64) { + if n < 0 { + r.SetParam("length", "") + } else { + setInt(&r.Message, "length", n) + } +} + // Validate validates the response intent and header parameter value format // (length, name, type, time, modified, location, reason, select) func (r *Response) Validate() error { |