Skip to content

Commit

Permalink
Cleanup readChunkData function
Browse files Browse the repository at this point in the history
  • Loading branch information
vvidic committed Jul 19, 2020
1 parent ed601a7 commit ee0104a
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions mjpeg-proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,19 @@ func readChunkHeader(reader *bufio.Reader) (head []byte, size int, err error) {
return
}

func readChunkData(reader *bufio.Reader, size int) (buf []byte, err error) {
buf = make([]byte, size)
err = nil
func readChunkData(reader *bufio.Reader, size int) ([]byte, error) {
buf := make([]byte, size)

pos := 0
for pos < size {
var n int
n, err = reader.Read(buf[pos:])
for pos := 0; pos < size; {
n, err := reader.Read(buf[pos:])
if err != nil {
return
return nil, err
}

pos += n
}

return
return buf, nil
}

func getBoundary(resp http.Response) (string, error) {
Expand Down

0 comments on commit ee0104a

Please sign in to comment.