You are here: Re: SOAP and Accept-Encoding « PHP Programming Language « IT news, forums, messages
Re: SOAP and Accept-Encoding

Posted by Mike P2 on 04/30/07 23:23

JW wrote:
> I also tried SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 9 to
> set the compression level, as I've seen in some examples.

I don't see anything wrong with the way you're trying to use
compression, but setting the compression level like this bothers me.
It doesn't make much sense, binary operators shouldn't work like that.

When you pass flags with the pipe, the flags are powers of two so that
they each have a one in a different place in the binary byte, for
example whichever flag was given the value of 2 would be 00000010, the
next flag would be given the value of 4 (00000100), the next would be
8 (00001000). The binary or operator (|) will return a number that has
ones in all places on the other numbers where there is a one, IE:

<?php
define( 'SOAP_COMPRESSION_ACCEPT', 2 ); // 00000010
define( 'SOAP_COMPRESSION_GZIP', 4 ); // 00000100
define( 'SOME_OTHER_CONSTANT', 16 ); // 00010000

echo SOAP_COMPRESSION_ACCEPT |
SOAP_COMPRESSION_GZIP |
SOME_OTHER_CONSTANT;
?>

the flags are combined, yielding 00010110, which is binary for 22, so
it will echo the number 22. Now, when you also combine in the number
9, which is 00001001, you will get 00011111. This messes things up
because normally the receiving function, something like this...

function doStuff( $flags )
{
if( $flags & SOME_OTHER_CONSTANT )
doIt();
}

....might get confused. The function will be checking to see where the
ones are (with the & operator), and an arbitrary number could throw in
a one anywhere, so it's left with complete BS. It will then have
unexpected consequences because it will see the one somewhere that
some unrelated flag would normally put a one. So there goes the
setting compression level thing.

BTW, where did you see those contrary examples?

-Mike PII

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация