Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix content-type cleaning if provided an array #155

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private function header_callback($ch, $headers){
$value = trim($parts[1]);

// this must be a header: value line
$this->response->headers->set($name, $value, false);
$this->response->headers->set($name, $value, true);

} else if($this->status_found){

Expand Down
13 changes: 9 additions & 4 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

use Proxy\Config;

// strip away extra parameters text/html; charset=UTF-8
function clean_content_type($content_type){
return trim(preg_replace('@;.*@', '', $content_type));
/**
* Strip away extra parameters "text/html; charset=UTF-8"
* @param $content_type
* @return string
*/
function clean_content_type($content_type)
{
$content_type = (is_array($content_type) && count($content_type) > 0) ? $content_type[0] : $content_type;
return trim(preg_replace('@;.*@', '', $content_type));
}


if(!function_exists('starts_with')){

function starts_with($haystack, $needles){
Expand Down