Issue 17355: ChunkedReader shouldn't block waiting for more data if it can return something.
(t *testing.T)
| 189 | // Issue 17355: ChunkedReader shouldn't block waiting for more data |
| 190 | // if it can return something. |
| 191 | func TestChunkReadPartial(t *testing.T) { |
| 192 | pr, pw := io.Pipe() |
| 193 | go func() { |
| 194 | pw.Write([]byte("7\r\n1234567")) |
| 195 | }() |
| 196 | cr := NewChunkedReader(pr) |
| 197 | readBuf := make([]byte, 7) |
| 198 | n, err := cr.Read(readBuf) |
| 199 | if err != nil { |
| 200 | t.Fatal(err) |
| 201 | } |
| 202 | want := "1234567" |
| 203 | if n != 7 || string(readBuf) != want { |
| 204 | t.Fatalf("Read: %v %q; want %d, %q", n, readBuf[:n], len(want), want) |
| 205 | } |
| 206 | go func() { |
| 207 | pw.Write([]byte("xx")) |
| 208 | }() |
| 209 | _, err = cr.Read(readBuf) |
| 210 | if got := fmt.Sprint(err); !strings.Contains(got, "malformed") { |
| 211 | t.Fatalf("second read = %v; want malformed error", err) |
| 212 | } |
| 213 | |
| 214 | } |
| 215 | |
| 216 | // Issue 48861: ChunkedReader should report incomplete chunks |
| 217 | func TestIncompleteChunk(t *testing.T) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…