Skip to content
Merged
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
4 changes: 2 additions & 2 deletions examples/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
return new React\Http\Message\Response(
200,
[],
"Hello wörld!\n"
"Hello world!\n"
);
});

Expand All @@ -26,7 +26,7 @@
return new React\Http\Message\Response(
200,
[
'Content-Type' => 'text/plain'
'Content-Type' => 'text/plain; charset=utf-8'
],
"Hello " . $escape($request->getAttribute('name')) . "!\n"
);
Expand Down
6 changes: 5 additions & 1 deletion src/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,17 +260,21 @@ private function sendResponse(ServerRequestInterface $request, ResponseInterface
$response = $response->withHeader('Content-Length', (string)$response->getBody()->getSize());
}

// remove default "Content-Type" header set by PHP
// remove default "Content-Type" header set by PHP (default_mimetype)
if (!$response->hasHeader('Content-Type')) {
header('Content-Type: foo');
header_remove('Content-Type');
}

// send all headers without applying default "; charset=utf-8" set by PHP (default_charset)
$old = ini_get('default_charset');
ini_set('default_charset', '');
foreach ($response->getHeaders() as $name => $values) {
foreach ($values as $value) {
header($name . ': ' . $value);
}
}
ini_set('default_charset', $old);

$body = $response->getBody();

Expand Down
8 changes: 4 additions & 4 deletions tests/acceptance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ skipif() {
echo "$out" | grep "$@" >/dev/null && echo -n S && return 1 || return 0
}

out=$(curl -v $base/ 2>&1); match "HTTP/.* 200"
out=$(curl -v $base/test 2>&1); match -i "Location: /"
out=$(curl -v $base/invalid 2>&1); match "HTTP/.* 404"
out=$(curl -v $base/ 2>&1); match "HTTP/.* 200" && match -iv "Content-Type:"
out=$(curl -v $base/test 2>&1); match -i "Location: /" && match -iP "Content-Type: text/html[\r\n]"
out=$(curl -v $base/invalid 2>&1); match "HTTP/.* 404" && match -iP "Content-Type: text/html[\r\n]"
out=$(curl -v $base// 2>&1); match "HTTP/.* 404"
out=$(curl -v $base/ 2>&1 -X POST); match "HTTP/.* 405"

Expand Down Expand Up @@ -56,7 +56,7 @@ out=$(curl -v $base/query?q=a%00b 2>&1); match "HTTP/.* 200" && m
out=$(curl -v $base/query?q=a\&q=b 2>&1); match "HTTP/.* 200" && match "{\"q\":\"b\"}"
out=$(curl -v $base/query?q%5B%5D=a\&q%5B%5D=b 2>&1); match "HTTP/.* 200" && match "{\"q\":[[]\"a\",\"b\"[]]}"

out=$(curl -v $base/users/foo 2>&1); match "HTTP/.* 200" && match "Hello foo!"
out=$(curl -v $base/users/foo 2>&1); match "HTTP/.* 200" && match "Hello foo!" && match -iP "Content-Type: text/plain; charset=utf-8[\r\n]"
out=$(curl -v $base/users/w%C3%B6rld 2>&1); match "HTTP/.* 200" && match "Hello wörld!"
out=$(curl -v $base/users/w%F6rld 2>&1); match "HTTP/.* 200" && match "Hello w�rld!" # demo expects UTF-8 instead of ISO-8859-1
out=$(curl -v $base/users/a+b 2>&1); match "HTTP/.* 200" && match "Hello a+b!"
Expand Down