| @@ -44,26 +44,22 @@ | ||
| 44 | 44 | } |
| 45 | 45 | return array('stream' => $stream); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - public function writeStream($chunk) { | |
| 49 | - if (strlen($chunk) > 0) { | |
| 50 | - $bvb64_prefix = ""; | |
| 48 | + public function writeStream($_string) { | |
| 49 | + if (strlen($_string) > 0) { | |
| 50 | + $chunk = ""; | |
| 51 | 51 | if ($this->bvb64stream) { |
| 52 | 52 | $chunk_size = $this->bvb64cksize; |
| 53 | - $chunk = $this->base64Encode($chunk, $chunk_size); | |
| 54 | - $bvb64_prefix .= "BVB64" . ":"; | |
| 53 | + $_string = $this->base64Encode($_string, $chunk_size); | |
| 54 | + $chunk .= "BVB64" . ":"; | |
| 55 | 55 | } |
| 56 | - | |
| 57 | - $hash_prefix = ""; | |
| 56 | + $chunk .= (strlen($_string) . ":" . $_string); | |
| 58 | 57 | if ($this->checksum == 'crc32') { |
| 59 | - $hash_prefix .= "CRC32" . ":" . crc32($chunk) . ":"; | |
| 58 | + $chunk = "CRC32" . ":" . crc32($_string) . ":" . $chunk; | |
| 60 | 59 | } else if ($this->checksum == 'md5') { |
| 61 | - $hash_prefix .= "MD5" . ":" . md5($chunk) . ":"; | |
| 60 | + $chunk = "MD5" . ":" . md5($_string) . ":" . $chunk; | |
| 62 | 61 | } |
| 63 | - | |
| 64 | - $chunk = $hash_prefix . $bvb64_prefix . strlen($chunk) . ":" . $chunk; | |
| 65 | - | |
| 66 | 62 | $this->writeChunk($chunk); |
| 67 | 63 | } |
| 68 | 64 | } |
| 69 | 65 | } |
| @@ -68,20 +64,18 @@ | ||
| 68 | 64 | } |
| 69 | 65 | } |
| 70 | 66 | |
| 71 | 67 | class BVRespStream extends BVStream { |
| 72 | - public $bvboundry; | |
| 73 | - | |
| 74 | 68 | function __construct($request) { |
| 75 | 69 | parent::__construct($request); |
| 76 | - $this->bvboundry = $request->bvboundry; | |
| 77 | 70 | } |
| 78 | 71 | |
| 79 | - public function writeChunk($chunk) { | |
| 80 | - echo $this->bvboundry . "ckckckckck" . $chunk . $this->bvboundry . "ckckckckck"; | |
| 72 | + public function writeChunk($_string) { | |
| 73 | + echo "ckckckckck".$_string."ckckckckck"; | |
| 81 | 74 | } |
| 75 | + | |
| 82 | 76 | public function endStream() { |
| 83 | - echo $this->bvboundry . "rerererere"; | |
| 77 | + echo "rerererere"; | |
| 84 | 78 | |
| 85 | 79 | return array(); |
| 86 | 80 | } |
| 87 | 81 | } |
| @@ -213,9 +207,9 @@ | ||
| 213 | 207 | stream_set_timeout($this->conn, 300); |
| 214 | 208 | while (!feof($this->conn)) { |
| 215 | 209 | $line = fgets($this->conn, 4096); |
| 216 | 210 | if (1 == $state) { |
| 217 | - if (!WPRHelper::safePregMatch('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/', $line, $m)) { | |
| 211 | + if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/', $line, $m)) { | |
| 218 | 212 | $response['httperror'] = "Status code line invalid: ".htmlentities($line); |
| 219 | 213 | return $response; |
| 220 | 214 | } |
| 221 | 215 | $response['http_version'] = $m[1]; |
| @@ -228,9 +222,9 @@ | ||
| 228 | 222 | if ($conlen > 0) |
| 229 | 223 | $response['body'] = fread($this->conn, $conlen); |
| 230 | 224 | return $response; |
| 231 | 225 | } |
| 232 | - if (!WPRHelper::safePregMatch('/([^:]+):\\s*(.*)/', $line, $m)) { | |
| 226 | + if (!preg_match('/([^:]+):\\s*(.*)/', $line, $m)) { | |
| 233 | 227 | // Skip to the next header |
| 234 | 228 | continue; |
| 235 | 229 | } |
| 236 | 230 | $key = strtolower(trim($m[1])); |