| @@ 704-719 (lines=16) @@ | ||
| 701 | * @param array $server Associative array similar to $_SERVER |
|
| 702 | * @return array Headers extracted from the input |
|
| 703 | */ |
|
| 704 | public function get_headers($server) { |
|
| 705 | $headers = array(); |
|
| 706 | // CONTENT_* headers are not prefixed with HTTP_ |
|
| 707 | $additional = array('CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true); |
|
| 708 | ||
| 709 | foreach ($server as $key => $value) { |
|
| 710 | if ( strpos( $key, 'HTTP_' ) === 0) { |
|
| 711 | $headers[ substr( $key, 5 ) ] = $value; |
|
| 712 | } |
|
| 713 | elseif ( isset( $additional[ $key ] ) ) { |
|
| 714 | $headers[ $key ] = $value; |
|
| 715 | } |
|
| 716 | } |
|
| 717 | ||
| 718 | return $headers; |
|
| 719 | } |
|
| 720 | ||
| 721 | /** |
|
| 722 | * Check if the current request accepts a JSON response by checking the endpoint suffix (.json) or |
|
| @@ 741-755 (lines=15) @@ | ||
| 738 | * @param array $server Associative array similar to $_SERVER |
|
| 739 | * @return array Headers extracted from the input |
|
| 740 | */ |
|
| 741 | public function get_headers($server) { |
|
| 742 | $headers = array(); |
|
| 743 | // CONTENT_* headers are not prefixed with HTTP_ |
|
| 744 | $additional = array('CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true); |
|
| 745 | ||
| 746 | foreach ($server as $key => $value) { |
|
| 747 | if ( strpos( $key, 'HTTP_' ) === 0) { |
|
| 748 | $headers[ substr( $key, 5 ) ] = $value; |
|
| 749 | } elseif ( isset( $additional[ $key ] ) ) { |
|
| 750 | $headers[ $key ] = $value; |
|
| 751 | } |
|
| 752 | } |
|
| 753 | ||
| 754 | return $headers; |
|
| 755 | } |
|
| 756 | ||
| 757 | } |
|
| 758 | ||
| @@ 747-761 (lines=15) @@ | ||
| 744 | * @param array $server Associative array similar to $_SERVER |
|
| 745 | * @return array Headers extracted from the input |
|
| 746 | */ |
|
| 747 | public function get_headers($server) { |
|
| 748 | $headers = array(); |
|
| 749 | // CONTENT_* headers are not prefixed with HTTP_ |
|
| 750 | $additional = array('CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true); |
|
| 751 | ||
| 752 | foreach ($server as $key => $value) { |
|
| 753 | if ( strpos( $key, 'HTTP_' ) === 0) { |
|
| 754 | $headers[ substr( $key, 5 ) ] = $value; |
|
| 755 | } elseif ( isset( $additional[ $key ] ) ) { |
|
| 756 | $headers[ $key ] = $value; |
|
| 757 | } |
|
| 758 | } |
|
| 759 | ||
| 760 | return $headers; |
|
| 761 | } |
|
| 762 | ||
| 763 | } |
|
| 764 | ||