Salve a tutti,
Sto lavorando un po' con i socket in PHP e dopo che ho fatto il mio bel GET ricevo dal server una pagina con un po' di header e del testo che compresso con gzip.
il codice che ho realizzato io questo:
e il testo che ottengo io questo:Codice PHP:
<?php
$socket = fsockopen ("", 80);
fwrite ($socket, "GET HTTP/1.1\r\n");
fwrite ($socket, "Host: \r\n");
fwrite ($socket, "User-Agent:\r\n");
fwrite ($socket, "X-Apple-Store-Front: 143441-1\r\n");
[altri header]
fwrite ($socket, "Connection: Keep-Alive\r\n\r\n"); // da notare il doppio a capo
while (!feof ($socket)) {
$part = fgets ($socket, 255);
print $part ;
}
fclose ($socket);
?>
Come vedete la prima parte non compressa mentre la seconda parte si.. come faccio a far si che la seconda parte venga decompressa?HTTP/1.1 200 OK Content-Type: text/xml x-apple-application-site: CUP X-Apple-Partner: origin.0 Vary: X-Apple-Store-Front Vary: Accept-Encoding x-webobjects-loadaverage: 0 x-apple-application-instance: 1101 x-apple-date-generated: Sun, 14 Mar 2010 21:45:22 GMT x-apple-request-store-front: 143441-1 x-apple-max-age: 3600 x-apple-asset-version: 70761 Content-Encoding: gzip Cache-Control: max-age=310 Date: Sun, 14 Mar 2010 21:51:55 GMT Content-Length: 8336 Connection: keep-alive
=w>ٝM0[HO&i3_z '4W_-#I;6/4}ceK,יu՞ҕ c,f/N])cuW>sV %Ԇ̺0<w%[*C-Ʋjw>0Br7RiO+ ]õgm!ۛia~5XJ:JOx*?QO ^ w |zh6OG>˘Q|[M F(L@#˿߄{.:>|e G'~UlkP `n@w2o -~6ZnTmh|x7 k]3.z2&+Ԫ1\0oWM,[4 TLONAiQwl%xнYZC? yC},}d,HDTnA%M& OB+h>co>]su,[5NK"=@s{7 [3N"I\O^;q .ӂҍ熶XЁ"_ϟ Q2~D~~aKE'#s$%"] ZqvkX[~@'3 _G$v> v-bY:f胖Щۖ; r lNN[&m\qs}RJr2}m<}}d"^P5t` [|,]]|tK!?3a"%Ӧ)B#[ E^a<Qp$ p)3`ZPHC<'WLCw`e /E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t@˼{y'ZunCf }B ;v60o4D ܈Q")G GQ X EB0uf3ޓR\י4 6,%ň+n)HYiz|[.g= )B ҝA{DYs`([+lw=ɰ9H rᣃaeGHc)4K6qn- 7D $CT;PtJ.0%j:PBAD ZL+ڃc)>:ؕ%l|Kɽb_t-#lP?FL]XXR?{r XST˹wEV4]|t^CeŐW?BFOY !͍'MXQlg4?O17KjpApº8]\3j0&3G0T13)j@(KQ D r=@ͨHrCyHe]THu6#Ӗ6cMyp:?77ݐh0"*n٤n )yĵ}$Nķ\L|-8)0pgՔa3iĴ0)3;fTѰ:tϣ'tw0(߯ >eٿK I&ks3aܗ;´h6 mg߄~<'8s`+ێ̼"ܺW&mƢaA r Zed_ej|tj;pȨ&hHK;#XP_*pf&P! 0X[祒4> tq<T)^?dPP(y(<J %B|wbI`_fxŗ_!s]GL#m)_={}зӾ)XT#D"(39oYwTCaA½?>r@;Ryز| m8t(<r 9ǡsMީBC!硐Py(<r 9BC!硐Py(<r>!F[#B\T}:3 X:HO <dnYgm q_,Iɖ Zz!j8Ki9peeSGATG|dՉe>k UNh4E3x04UXO4E)6cѤOreC1 ucCq'Ε߽b>#?Łқ%B8"&>|jD N -Cei kO{O!KxA&N)' %Ru<@;n^Xʳ&dm;$=P{ #4P2:V 6%oL.`@2m?niU57ώ! `G RYA;&ͤք^#.{/.[/oE}Tg >|-mYUM V#"rXXߎd@]s d'w/)UHI|]O%7y{:NtmKȷEY*A ;rOZ]p1]'~-27KW nHZ "2["r{%=ksM!ݓԯՏ8G^aS` |LcC_eu'fѲphg_PdzWе W3Jϸ|L8.dr/,%FEqgmN]K4 c_AQ(bg/'~W@$f$;="~E$p >Sj"aEÊ<1y^Ċ
Io ho provato a fare come segue, senza successo![]()
![]()
grazie mille a tutti per l'aiutoCodice PHP:
while (!feof ($socket)) {
$part = fgets ($socket);
$decompr = gzuncompress($part);
print $decompr;
}
![]()