Post by stefan_m » Sat Aug 15, 2009 8:33 pm

hello,

at first, thanks for your great solution, very very well... tiny, simple and very fast. THANK YOU!

response.php

the lines which dealing with the accepted encoding given an incorrect answer

Code: Select all

if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
    $encoding = 'gzip';
} 

if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip')) {
    $encoding = 'x-gzip';
}

Code: Select all

echo $_SERVER['HTTP_ACCEPT_ENCODING'] ; 
gzip,deflate // gzip at first position

Code: Select all

var_dump (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip'));
int(0)

Code: Select all

var_dump (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip'));
bool(false)

Code: Select all

if (strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) {
    echo 'gzip accepted';
} else {
    echo 'result of int(0) seems to be interpreted as false in if-condition';
}
result of int(0) seems to be interpreted as false in if-condition
the solution is to check if strpos not false

Code: Select all

if (isset($_SERVER['HTTP_ACCEPT_ENCODING'])
    && strpos ($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false) {
    $encoding = 'gzip';
}
elseif (isset($_SERVER['HTTP_ACCEPT_ENCODING'])
    && strpos ($_SERVER['HTTP_ACCEPT_ENCODING'],'x-gzip') !== false) {
    $encoding = 'x-gzip';
}
this working in my case and maybe also in others.

ciao, Stefan

Newbie

Posts

Joined
Sat Aug 15, 2009 7:39 pm

Post by Daniel » Sat Aug 15, 2009 8:53 pm

ok thanks!

I have added this to the next release.

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by SuperJuice » Sun Aug 16, 2009 6:33 am

Very nice find stefan_m, well done! 8)

Active Member

Posts

Joined
Thu Aug 13, 2009 12:06 pm

Post by stefan_m » Sun Aug 16, 2009 9:31 pm

hello juice,

thanks, but its not really a big thing, i am just wondering about the missing compression, so i found it.

adios, stefan

PS: You can call me "stefan" thats enough. "stefan_m" looks strange :-)

Newbie

Posts

Joined
Sat Aug 15, 2009 7:39 pm

Post by banane » Mon Sep 14, 2009 10:13 pm

just a question, why scripts and css are not compressed?
thanks

User avatar
New member

Posts

Joined
Fri Jul 31, 2009 6:30 pm

Who is online

Users browsing this forum: No registered users and 10 guests