@@ -475,6 +475,7 @@ |
||
475 | 475 | |
476 | 476 | /** |
477 | 477 | * Adjust the headers by injecting default values for missing keys. |
478 | + * @param string $requestType |
|
478 | 479 | */ |
479 | 480 | private function adjustHeaders($requestType) |
480 | 481 | { |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | |
206 | 206 | $ms = $this->appendPayloadToRequest($ms); |
207 | 207 | |
208 | - if (! $this->isConnected()) { |
|
208 | + if (!$this->isConnected()) { |
|
209 | 209 | $this->connect(); |
210 | 210 | } |
211 | 211 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | */ |
231 | 231 | private function checkConnection($start) |
232 | 232 | { |
233 | - if (! $this->ready()) { |
|
233 | + if (!$this->ready()) { |
|
234 | 234 | if (time() - $start > $this->timeout) { |
235 | 235 | $this->disconnect(); |
236 | 236 | throw new HttpException("Connection timed out!"); |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | $numBytes = 1; |
338 | 338 | $start = time(); |
339 | 339 | while (true) { |
340 | - if (! $this->checkConnection($start)) { |
|
340 | + if (!$this->checkConnection($start)) { |
|
341 | 341 | continue; |
342 | 342 | } |
343 | 343 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | $start = time(); // we have readen something => adjust timeout start point |
351 | 351 | $tmp .= $c; |
352 | 352 | |
353 | - if (! $delimiterFound) { |
|
353 | + if (!$delimiterFound) { |
|
354 | 354 | $this->handleHeader($delimiterFound, $numBytes, $tmp); |
355 | 355 | } |
356 | 356 | |
@@ -373,9 +373,9 @@ discard block |
||
373 | 373 | // Set pointer to start |
374 | 374 | $this->payload->reset(); |
375 | 375 | |
376 | - if(Arrays::hasElement($this->headers, 'Content-Encoding')) { |
|
376 | + if (Arrays::hasElement($this->headers, 'Content-Encoding')) { |
|
377 | 377 | $mayCompressed = $this->payload->read($this->payload->count()); |
378 | - switch($this->headers['Content-Encoding']) { |
|
378 | + switch ($this->headers['Content-Encoding']) { |
|
379 | 379 | case 'gzip': |
380 | 380 | $uncompressed = gzdecode(strstr($mayCompressed, "\x1f\x8b")); |
381 | 381 | $this->payload->flush(); |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | 'rqtype' => $requestType, |
433 | 433 | 'path' => $this->path, |
434 | 434 | 'proto' => $this->protocol, |
435 | - 'query' => (strlen($this->queryString) ? '?' . $this->queryString : '') |
|
435 | + 'query' => (strlen($this->queryString) ? '?'.$this->queryString : '') |
|
436 | 436 | )); |
437 | 437 | |
438 | 438 | // Add the host part |
@@ -478,23 +478,23 @@ discard block |
||
478 | 478 | */ |
479 | 479 | private function adjustHeaders($requestType) |
480 | 480 | { |
481 | - if (! array_key_exists('Accept', $this->headers) && $requestType != 'HEAD') { |
|
481 | + if (!array_key_exists('Accept', $this->headers) && $requestType != 'HEAD') { |
|
482 | 482 | $this->setHeader('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'); |
483 | 483 | } |
484 | 484 | |
485 | - if (! array_key_exists('Accept-Language', $this->headers) && $requestType != 'HEAD') { |
|
485 | + if (!array_key_exists('Accept-Language', $this->headers) && $requestType != 'HEAD') { |
|
486 | 486 | $this->setHeader('Accept-Language', 'en-US;q=0.7,en;q=0.3'); |
487 | 487 | } |
488 | 488 | |
489 | - if (! array_key_exists('User-Agent', $this->headers) && $requestType != 'HEAD') { |
|
489 | + if (!array_key_exists('User-Agent', $this->headers) && $requestType != 'HEAD') { |
|
490 | 490 | $this->setHeader('User-Agent', 'phpGenerics 1.0'); |
491 | 491 | } |
492 | 492 | |
493 | - if (! array_key_exists('Connection', $this->headers) || strlen($this->headers['Connection']) == 0) { |
|
493 | + if (!array_key_exists('Connection', $this->headers) || strlen($this->headers['Connection']) == 0) { |
|
494 | 494 | $this->adjustConnectionHeader($requestType); |
495 | 495 | } |
496 | 496 | |
497 | - if (! array_key_exists('Accept-Encoding', $this->headers)) { |
|
497 | + if (!array_key_exists('Accept-Encoding', $this->headers)) { |
|
498 | 498 | $encoding = ""; |
499 | 499 | if (function_exists('gzinflate')) { |
500 | 500 | $encoding = 'gzip, deflate'; |
@@ -498,8 +498,7 @@ |
||
498 | 498 | $encoding = ""; |
499 | 499 | if (function_exists('gzinflate')) { |
500 | 500 | $encoding = 'gzip, deflate'; |
501 | - } |
|
502 | - else { |
|
501 | + } else { |
|
503 | 502 | $encoding = 'identity'; |
504 | 503 | } |
505 | 504 | $this->setHeader('Accept-Encoding', $encoding); |