I have a skin that has been working correctly for several years, but recently quite often fails when trying to match the RegExp in the WebParser measure.
My investigations have shown that the web server at the URL specified in the WebParser measure is sometimes sending a plain text response which is fine and is correctly matched, but other times is sending a compressed (GZIP) response which cannot be matched correctly.
Can the WebParser measure handle and decode compressed (GZIP) responses?
It is currently May 4th, 2024, 2:55 pm
WebParser - GZIP web server responses
-
- Posts: 1
- Joined: August 21st, 2020, 4:31 pm
-
- Rainmeter Sage
- Posts: 2617
- Joined: March 23rd, 2015, 5:26 pm
Re: WebParser - GZIP web server responses
I don't think so either. Perhaps try adding a header "Accept: text/html" ???
-
- Developer
- Posts: 22631
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: WebParser - GZIP web server responses
WebParser is certainly not going to be able to deal with anything that isn't just UTF-8 "text".
-
- Rainmeter Sage
- Posts: 16198
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
-
- Developer
- Posts: 22631
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: WebParser - GZIP web server responses
I have not seen any evidence that that will in any way work.balala wrote: ↑August 21st, 2020, 5:20 pm However: https://forum.rainmeter.net/viewtopic.php?f=5&t=35892&start=10#p182030
-
- Rainmeter Sage
- Posts: 16198
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: WebParser - GZIP web server responses
Agree. Neither me haven't seen, but when I saw Yincognito's post have done a correlation and posted the link. Didn't try it out and now I can't either.
-
- Rainmeter Sage
- Posts: 7198
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: WebParser - GZIP web server responses
I don't know about handling - you might want to try using some headers to see if you can force a decompressed response - but decoding, I don't think so.
However, what you can do is download the response (using WebParser's appropriate options), then use the command line version of WinZip, 7Zip or some other compression/decompression tool with RunCommand to get the decompressed output in another file (or, apparently, even to STDOUT which can be directly processed further in the RunCommand measure using a RegExp Substitute), which can be then parsed locally the normal way using your regexes. It's a bit of a convoluted process, but I believe it can be done. You can investigate if the response is compressed or not by handling the header, like this (see the comment too) or even try to parse the response and rate it compressed on parsing failure.
Other than that, some interesting links and tools regarding this, here, here and here (not sure why the latter 2 give different results for the same string, maybe it's a text vs file compression thing) - or you can search yourself other tools that do this in various languages (including PHP).
Yeah, that doesn't have much to do with the things being discussed in this thread - that was about parsing an EXE file to get the version of Rainmeter, not about parsing a GZIP encoded file to decompress it. Sorry.
P.S. Maybe some simple link/samples of what you're trying to parse would help, just to see if we can make the whole process successful in a basic skin...