Skip to content

Commit

Permalink
Fix Kasa KC200 cameras
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed May 10, 2024
1 parent ee387b7 commit ec92303
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions pkg/kasa/producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,25 @@ func Dial(url string) (*Producer, error) {
return nil, err
}

rd := struct {
io.Reader
io.Closer
}{
httputil.NewChunkedReader(res.Body),
res.Body,
// KC200
// HTTP/1.0 200 OK
// Server: Streamd,
// Content-Type: multipart/x-mixed-replace;boundary=data-boundary--
rd := res.Body

// KD110, KC401, KC420WS:
// HTTP/1.0 200 OK
// Content-Type: multipart/x-mixed-replace;boundary=data-boundary--
// Transfer-Encoding: chunked
if res.Header.Get("Transfer-Encoding") == "chunked" {
// HTTP/1.0 + chunked = out of standard, so need to use this construction:
rd = struct {
io.Reader
io.Closer
}{
httputil.NewChunkedReader(res.Body),
res.Body,
}
}

prod := &Producer{rd: core.NewReadBuffer(rd)}
Expand Down

0 comments on commit ec92303

Please sign in to comment.