It is currently April 25th, 2024, 1:26 am

WebParser - GZIP web server responses

Get help with creating, editing & fixing problems with skins
dw-dev
Posts: 1
Joined: August 21st, 2020, 4:31 pm

WebParser - GZIP web server responses

Post by dw-dev »

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?
User avatar
SilverAzide
Rainmeter Sage
Posts: 2605
Joined: March 23rd, 2015, 5:26 pm

Re: WebParser - GZIP web server responses

Post by SilverAzide »

I don't think so either. Perhaps try adding a header "Accept: text/html" ???
Gadgets Wiki GitHub More Gadgets...
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WebParser - GZIP web server responses

Post by jsmorley »

WebParser is certainly not going to be able to deal with anything that isn't just UTF-8 "text".
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: WebParser - GZIP web server responses

Post by balala »

jsmorley wrote: August 21st, 2020, 5:05 pm WebParser is certainly not going to be able to deal with anything that isn't just UTF-8 "text".
However: https://forum.rainmeter.net/viewtopic.php?f=5&t=35892&start=10#p182030
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: WebParser - GZIP web server responses

Post by jsmorley »

I have not seen any evidence that that will in any way work.
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: WebParser - GZIP web server responses

Post by balala »

jsmorley wrote: August 21st, 2020, 5:23 pm I have not seen any evidence that that will in any way work.
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.
User avatar
Yincognito
Rainmeter Sage
Posts: 7157
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: WebParser - GZIP web server responses

Post by Yincognito »

dw-dev wrote: August 21st, 2020, 4:44 pmCan the WebParser measure handle and decode compressed (GZIP) 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).
balala wrote: August 21st, 2020, 6:38 pm
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.
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. :confused:

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...
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth