public function testClearHeadersCharset() { $header = "HTTP/1.1 200 OK" . "\r\n" . "Content-Type: text/html; charset=Shift-JIS"; $response = Response::fromString("{$header}\r\n\r\nABC"); $c = Filter::clearHeadersCharset($response->getHeaders()->toArray()); $this->assertEquals('text/html', $c['Content-Type']); }
public function getHeader($header, $first = true) { $value = parent::getHeader($header, $first); if ('Content-type' == ucwords(strtolower($header))) { $args = func_get_args(); if (isset($args[2]) && true === $args[2]) { return parent::getHeader($header, $first); } return Filter::replaceHeaderCharset($value); } return $value; }
/** * {@inheritdoc} */ public function onRequestComplete(Event $event) { if ($res = $event['request']->getResponse()) { $contentType = $res->getHeader('content-type', true); $redirect = $res->getHeader('Location'); if (!empty($redirect) || !preg_match('#^text/html#i', $contentType)) { return; } $bodyEntity = $res->getBody(false); $body = $this->getCharsetFront()->convert((string) $bodyEntity, array('content-type' => $contentType, 'url' => $event['request']->getUrl())); $res->setHeader('content-type', Filter::replaceHeaderCharset($contentType)); $bodyEntity->seek(0, SEEK_SET); $bodyEntity->write($body); } }
public function getFieldValue() { return Filter::replaceHeaderCharset($this->value); }