Re: How do I deflate content()?
ser <ser.avzdoo-NUepA2SMhDQqspMVqqL2D+4xXEVPTSb/[email protected]> Sun, 25 Dec 2022 08:50:19 +0000
| Newsgroups | gmane.music.equipment.slimdevices.devel |
|---|---|
| Organization | Logitech Squeezebox Forums |
| Message-ID | <[email protected]> |
Here's a full request, with debug enabled:
Code:
--------------------
[22-12-25 02:32:05.2112] Plugins::Assistant::HASS::getEntity (102) Get Entity: http://XX.XX.XX.XX/api/states
[22-12-25 02:32:05.2119] Slim::Networking::SimpleHTTP::Base::_createHTTPRequest (96) GETing http://XX.XX.XX.XX/api/states
[22-12-25 02:32:05.2136] Slim::Networking::Async::connect (108) Connecting to XX.XX.XX.XX
[22-12-25 02:32:05.2156] Slim::Networking::Async::_async_connect (196) Slim::Networking::Async::Socket::HTTP=GLOB(0x56142f8e82a0) => 43 connected, ready to write request
[22-12-25 02:32:05.2165] Slim::Networking::Async::write_async (226) Sending: [GET /api/states HTTP/1.0
Connection: close
Cache-Control: no-cache
Accept: */*
Accept-Encoding: deflate, gzip
Accept-Language: en
Authorization: Bearer XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Host: XX.XX.XX.XX
User-Agent: iTunes/4.7.1 (Linux; N; Debian; x86_64-linux; EN; utf8) SqueezeCenter, Squeezebox Server, Logitech Media Server/8.3.0/1667251155
Content-Type: application/json
Charset: UTF-8
Icy-Metadata: 1
]
[22-12-25 02:32:05.2346] Slim::Networking::Async::HTTP::_http_read (430) Headers read. code: 200 status: OK
[22-12-25 02:32:05.2357] Slim::Networking::Async::HTTP::_http_read (431) bless({
"::std_case" => { "set-cookie" => "Set-Cookie", "set-cookie2" => "Set-Cookie2" },
"content-encoding" => "deflate",
"content-length" => 20_736,
"content-type" => "application/json",
date => "Sun, 25 Dec 2022 08:32:05 GMT",
server => "Python/3.10 aiohttp/3.8.1",
}, "HTTP::Headers")
[22-12-25 02:32:05.2367] Slim::Networking::Async::HTTP::_http_read_body (530) Read body: [851] bytes
[22-12-25 02:32:05.2375] Slim::Networking::Async::HTTP::_http_read_body (530) Read body: [16384] bytes
[22-12-25 02:32:05.2380] Slim::Networking::Async::HTTP::_http_read_body (530) Read body: [3501] bytes
[22-12-25 02:32:05.2383] Slim::Networking::Async::disconnect (251) Close Slim::Networking::Async::Socket::HTTP=GLOB(0x56142f8e82a0) => 43
[22-12-25 02:32:05.2387] Slim::Networking::Async::HTTP::_http_read_body (596) closing mode
[22-12-25 02:32:05.2389] Slim::Networking::Async::HTTP::_http_read_body (604) Body read
[22-12-25 02:32:05.2391] Slim::Networking::SimpleAsyncHTTP::onBody (133) status for http://XX.XX.XX.XX/api/states is 200 OK
[22-12-25 02:32:05.2397] Slim::Networking::SimpleAsyncHTTP::onBody (154) Done
[22-12-25 02:32:05.2426] Slim::Networking::IO::Select::__ANON__ (130) Error: Select task failed calling Slim::Networking::Async::HTTP::_http_read_body: malformed JSON string, neither array, object, number, string or atom, at character offset 0 (before "\x{fffd}\x{fffd}/\x{fffd}...") at /var/lib/squeezeboxserver/cache/InstalledPlugins/Plugins/Assistant/HASS.pm line 111.
; fh=Slim::Networking::Async::Socket::HTTP=GLOB(0x56142f8e82a0)
--------------------
As expected, the library is accepting deflate, and the Home Assistant
server is delivering deflate.
I couldn't figure out how to check the status of
Slim::Networking::SimpleHTTP::hasZlib. As I mentioned, zlib1g is in the
dependencies for the package:
Code:
--------------------
...
Package: logitechmediaserver
Version: 8.3.0
State: installed
...
Depends: perl (>= 5.10.0), adduser, libc6, libgcc1, libstdc++6, zlib1g,
libio-socket-ssl-perl, ca-certificates, libcrypt-openssl-rsa-perl
--------------------
I tried dumping the structure out with $log a couple of ways; how would
I inspect this? I did find the code in SimpleHTTP/Base.pm that only adds
the header for accepting compressed data IFF zlib is available, so
there's a secondary indication that it's there. $response->content is
certainly not deflating the data, though; is there a way I can do it
manually? I'm getting content, and it's still compressed by the time the
plugin gets it -- is there a simple function to uncompress it?
------------------------------------------------------------------------
ser's Profile: http://forums.slimdevices.com/member.php?userid=73240
View this thread: http://forums.slimdevices.com/showthread.php?t=117244