ReadStatusWithData reads a status, arguments, and any binary data. Note that the reader must be fully exhausted before invoking any other read methods.
()
| 181 | // ReadStatusWithData reads a status, arguments, and any binary data. Note that |
| 182 | // the reader must be fully exhausted before invoking any other read methods. |
| 183 | func (conn *PktlineConnection) ReadStatusWithData() (int, []string, io.Reader, error) { |
| 184 | args := make([]string, 0, 100) |
| 185 | status := 0 |
| 186 | seenStatus := false |
| 187 | for { |
| 188 | s, pktLen, err := conn.pl.ReadPacketTextWithLength() |
| 189 | if err != nil { |
| 190 | return 0, nil, nil, errors.NewProtocolError(tr.Tr.Get("error reading packet"), err) |
| 191 | } |
| 192 | if pktLen == 0 { |
| 193 | if !seenStatus { |
| 194 | return 0, nil, nil, errors.NewProtocolError(tr.Tr.Get("no status seen"), nil) |
| 195 | } |
| 196 | return 0, nil, nil, errors.NewProtocolError(tr.Tr.Get("unexpected flush packet"), nil) |
| 197 | } else if !seenStatus { |
| 198 | ok := false |
| 199 | if strings.HasPrefix(s, "status ") { |
| 200 | status, err = strconv.Atoi(s[7:]) |
| 201 | ok = err == nil |
| 202 | } |
| 203 | if !ok { |
| 204 | return 0, nil, nil, errors.NewProtocolError(tr.Tr.Get("expected status line, got %q", s), err) |
| 205 | } |
| 206 | seenStatus = true |
| 207 | } else if pktLen == 1 { |
| 208 | break |
| 209 | } else { |
| 210 | args = append(args, s) |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | return status, args, pktlineReader(conn.pl), nil |
| 215 | } |
| 216 | |
| 217 | // ReadStatusWithLines reads a status, arguments, and a set of text lines. |
| 218 | func (conn *PktlineConnection) ReadStatusWithLines() (int, []string, []string, error) { |
no test coverage detected