(line string)
| 113 | } |
| 114 | |
| 115 | func (p *inputParser) handlePayloadLine(line string) (inputEvent, error) { |
| 116 | if line == lineFunctionPayloadEnd { |
| 117 | p.readingPayload = false |
| 118 | p.currentFn.Payload = []byte(p.payloadBuf.String()) |
| 119 | fn := p.currentFn |
| 120 | p.currentFn = nil |
| 121 | p.payloadBuf.Reset() |
| 122 | return inputEvent{kind: inputEventCall, fn: fn}, nil |
| 123 | } |
| 124 | |
| 125 | if hasLinePrefix(line, lineFunctionCancel) { |
| 126 | event, err := parseCancelEvent(line) |
| 127 | if err != nil { |
| 128 | // Malformed cancel must not affect payload parser state. |
| 129 | return inputEvent{}, err |
| 130 | } |
| 131 | |
| 132 | if p.currentFn != nil && event.uid == p.currentFn.UID { |
| 133 | p.resetPayloadState() |
| 134 | event.preAdmission = true |
| 135 | } |
| 136 | return event, nil |
| 137 | } |
| 138 | |
| 139 | if hasLinePrefix(line, lineFunctionProgress) { |
| 140 | return parseProgressEvent(line), nil |
| 141 | } |
| 142 | |
| 143 | if line == lineQuit { |
| 144 | p.resetPayloadState() |
| 145 | return inputEvent{kind: inputEventQuit}, nil |
| 146 | } |
| 147 | |
| 148 | if hasLinePrefix(line, lineFunction) || strings.HasPrefix(line, lineFunction+"_") { |
| 149 | p.resetPayloadState() |
| 150 | return p.parseEvent(line) |
| 151 | } |
| 152 | |
| 153 | if p.payloadBuf.Len() > 0 { |
| 154 | p.payloadBuf.WriteByte('\n') |
| 155 | } |
| 156 | p.payloadBuf.WriteString(line) |
| 157 | |
| 158 | return inputEvent{}, nil |
| 159 | } |
| 160 | |
| 161 | func (p *inputParser) resetPayloadState() { |
| 162 | p.readingPayload = false |
no test coverage detected