Problems with GZIP
#1
I've developed a plugin that add a new page to MyBB. However, whenever I visit the page with GZIP compression enabled, it gives an "Invalid/unsupported compression" error. The really confusing part is that it only happens with my new page, and I can't for the life of me find what my page does differently to cause this.

I know the normal response is "turn off GZIP compression" but I want to know why my custom page, and only my page, doesn't work with it. This is, at the moment, the only plugin I have on my test board.

My plugin is the "Downloads Manager" in the Mods section, if you want to look through the source.
[Image: LogoO.png]
Reply
#2
So, no one has anything on this? No solutions, no "This should be fixed!" responses? I would go through and figure it out myself, but I'm busy with several other projects, including school.

Any core developers' comments on this?
[Image: LogoO.png]
Reply
#3
First off do you have an example url with the problem? Have you tried multiple browsers? I am confused also...is the problem plugin your download manager or something new?
Reply
#4
I've seen many threads where someone says "X doesn't work" and the solution is almost always "turn off GZIP."

In my case, only my custom page don't work using gzip, but the core forum software does, and from a quick look through the search, it looks to be a common problem. However, that was just a quick glance, so I could be wrong.

I've tried in both Firefox and Internet Exploder. FF gives me a "Invalid Encoding" error, and IE gives me a blank page.

The annoying thing is I can't see what my page isn't/is doing that the normal pages are/aren't.

I'd turn on GZIP for a demonstration but my downloads section is visited by the iPodWizard community for a few things I've developed, and I don't want to keep them from what they want to demonstrate.

I haven't tried copy+paste+modifying a core file and seeing if that works yet...
[Image: LogoO.png]
Reply
#5
My first guess would be the fact that in downloads.php, you've got a blank line at the end of the file. Try removing all blank lines before/after <?php and ?> tags.
Reply
#6
I'll try that and see if it works.

If it does, do you have any clue why? I wouldn't think that a newline would affect anything.

Then again, my downloads plugin is my first PHP project, and I'd only done some Perl work before that, so I admit I don't know a whole lot about PHP.
[Image: LogoO.png]
Reply
#7
gzip/php has a problem with spaces after the code. That's a known issue. Personally I don't know exactly why this happens. Probably something to do with the php parser.
Reply
#8
That makes sense. I'm glad I now know why it does it. If I sounded impatient, I'm sorry, I was just agitated about not knowing why my page would break even though it looked perfectly fine.

Thank you for your help! Now, next time someone has a similar problem, they have another answer to try.

Now, back to my projects...
[Image: LogoO.png]
Reply
#9
The reason it does it because it totally breaks the data.

A newline is defined in Windows as a carriage return, followed by a line feed (0x0D0A). Outputting this obviously breaks the CRC of the GZipped data. From memory, MyBB doesn't send a Content-Length header, so the browser will try to decompress the entire stream sent to it. Sending a Content-Length header might've prevented this in this particular case, but other newlines elsewhere would still break things.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)