Ticket #2831: class-snoopy.php.patch
| File class-snoopy.php.patch, 2.7 KB (added by Phantagom, 6 years ago) |
|---|
-
class-snoopy.php
7 7 Copyright (c): 1999-2000 ispi, all rights reserved 8 8 Version: 1.01 9 9 10 Added Gzip Support for Wordpress by Dennis Kruyt (http://kruyt.org). 11 10 12 * This library is free software; you can redistribute it and/or 11 13 * modify it under the terms of the GNU Lesser General Public 12 14 * License as published by the Free Software Foundation; either … … 100 102 // library functions built into php, 101 103 // as these functions are not stable 102 104 // as of this Snoopy release. 105 // send Accept-encoding: gzip? 106 var $use_gzip = true; 103 107 104 108 /**** Private variables ****/ 105 109 … … 802 806 } 803 807 if(!empty($this->accept)) 804 808 $headers .= "Accept: ".$this->accept."\r\n"; 809 810 if($this->use_gzip) { 811 // make sure PHP was built with --with-zlib 812 // and we can handle gzipp'ed data 813 if ( function_exists(gzinflate) ) { 814 $headers .= "Accept-encoding: gzip\r\n"; 815 } 816 else { 817 trigger_error( 818 "use_gzip is on, but PHP was built without zlib support.". 819 " Requesting file(s) without gzip encoding.", 820 E_USER_NOTICE); 821 } 822 } 823 805 824 if(!empty($this->referer)) 806 825 $headers .= "Referer: ".$this->referer."\r\n"; 807 826 if(!empty($this->cookies)) … … 853 872 $this->_redirectaddr = false; 854 873 unset($this->headers); 855 874 875 // content was returned gzip encoded? 876 $is_gzipped = false; 877 856 878 while($currentHeader = fgets($fp,$this->_maxlinelen)) 857 879 { 858 880 if ($this->read_timeout > 0 && $this->_check_timeout($fp)) … … 892 914 } 893 915 $this->response_code = $currentHeader; 894 916 } 895 917 if (preg_match("/Content-Encoding: gzip/", $currentHeader) ) { 918 $is_gzipped = true; 919 } 896 920 $this->headers[] = $currentHeader; 897 921 } 898 922 … … 905 929 $results .= $_data; 906 930 } while(true); 907 931 932 // gunzip 933 if ( $is_gzipped ) { 934 // per http://www.php.net/manual/en/function.gzencode.php 935 $results = substr($results, 10); 936 $results = gzinflate($results); 937 } 938 908 939 if ($this->read_timeout > 0 && $this->_check_timeout($fp)) 909 940 { 910 941 $this->status=-100;
