当前位置: 首页>>代码示例>>PHP>>正文


PHP Response::getCharset方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpFoundation\Response::getCharset方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::getCharset方法的具体用法?PHP Response::getCharset怎么用?PHP Response::getCharset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpFoundation\Response的用法示例。


在下文中一共展示了Response::getCharset方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCharset

 /**
  * @return string
  */
 protected function getCharset()
 {
     if ($this->response === null) {
         return null;
     }
     return $this->response->getCharset();
 }
开发者ID:ndrx-io,项目名称:profiler,代码行数:10,代码来源:Http.php

示例2: onEventResponse

 public function onEventResponse(Application $app, Response $response)
 {
     if (null === $response->getCharset()) {
         $response->setCharset($app->getParameter('charset'));
     }
     $response->prepare($app->getRequest());
 }
开发者ID:itlessons,项目名称:php-application,代码行数:7,代码来源:ResponseProvider.php

示例3: testGetCharset

 public function testGetCharset()
 {
     $response = new Response();
     $charsetOrigin = 'UTF-8';
     $response->setCharset($charsetOrigin);
     $charset = $response->getCharset();
     $this->assertEquals($charsetOrigin, $charset);
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:8,代码来源:ResponseTest.php

示例4: testFiltersSetsNonDefaultCharsetIfNotOverriddenOnNonTextContentType

 public function testFiltersSetsNonDefaultCharsetIfNotOverriddenOnNonTextContentType()
 {
     $listener = new ResponseListener('ISO-8859-15');
     $this->dispatcher->addListener(KernelEvents::RESPONSE, array($listener, 'onKernelResponse'), 1);
     $response = new Response('foo');
     $request = Request::create('/');
     $request->setRequestFormat('application/json');
     $event = new FilterResponseEvent($this->kernel, $request, HttpKernelInterface::MASTER_REQUEST, $response);
     $this->dispatcher->dispatch(KernelEvents::RESPONSE, $event);
     $this->assertEquals('ISO-8859-15', $response->getCharset());
 }
开发者ID:tejdeeps,项目名称:tejcs.com,代码行数:11,代码来源:ResponseListenerTest.php

示例5: logResponse

 protected function logResponse(Response $response, Request $request)
 {
     if ($response->getStatusCode() >= 500) {
         $color = LogLevel::ERROR;
     } elseif ($response->getStatusCode() >= 400) {
         $color = LogLevel::WARNING;
     } elseif ($response->getStatusCode() >= 300) {
         $color = LogLevel::NOTICE;
     } elseif ($response->getStatusCode() >= 200) {
         $color = LogLevel::INFO;
     } else {
         $color = LogLevel::INFO;
     }
     $msg = 'Response {response_status_code} for "{request_method} {request_uri}"';
     $context = array('request_method' => $request->getMethod(), 'request_uri' => $request->getRequestUri(), 'response_status_code' => $response->getStatusCode(), 'response_charset' => $response->getCharset(), 'response_date' => $response->getDate(), 'response_etag' => $response->getEtag(), 'response_expires' => $response->getExpires(), 'response_last_modified' => $response->getLastModified(), 'response_max_age' => $response->getMaxAge(), 'response_protocol_version' => $response->getProtocolVersion(), 'response_ttl' => $response->getTtl(), 'response_vary' => $response->getVary());
     $this->logger->log($color, $msg, $context);
 }
开发者ID:caxy,项目名称:drupal-console-logging-middleware,代码行数:17,代码来源:RequestLoggingMiddleware.php

示例6: filter

 /**
  * Filters the Response.
  *
  * @param EventInterface $event    An EventInterface instance
  * @param Response       $response A Response instance
  */
 public function filter(EventInterface $event, Response $response)
 {
     if (HttpKernelInterface::MASTER_REQUEST !== $event->get('request_type')) {
         return $response;
     }
     if (null === $response->getCharset()) {
         $response->setCharset($this->charset);
     }
     if ($response->headers->has('Content-Type')) {
         return $response;
     }
     $request = $event->get('request');
     $format = $request->getRequestFormat();
     if (null !== $format && ($mimeType = $request->getMimeType($format))) {
         $response->headers->set('Content-Type', $mimeType);
     }
     return $response;
 }
开发者ID:noelg,项目名称:symfony-demo,代码行数:24,代码来源:ResponseListener.php

示例7: getCharset

 /**
  * Get the response charset
  * @return string
  */
 public function getCharset()
 {
     return $this->response->getCharset();
 }
开发者ID:icedevelopment,项目名称:compressor-bundle,代码行数:8,代码来源:CompressionEvent.php

示例8: evaluateResponseMethodNotAllowed

 protected function evaluateResponseMethodNotAllowed(Response $response)
 {
     $this->assertEquals('UTF-8', $response->getCharset(), 'Test charset response');
     $this->assertEquals(405, $response->getStatusCode(), 'Test status code 405 ' . $response->getContent());
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:5,代码来源:ApiTestCase.php

示例9: evaluateResponse200

 private function evaluateResponse200(Response $response)
 {
     $this->assertEquals(200, $response->getStatusCode(), 'Test status code ');
     $this->assertEquals('UTF-8', $response->getCharset(), 'Test charset response');
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:5,代码来源:RSSFeedTest.php

示例10: serializeResponse

 /**
  * Serialize the response object ready for caching
  *
  * @param  \Symfony\Component\HttpFoundation\Response   $response
  *
  * @return string
  */
 public function serializeResponse(Response $response)
 {
     return array('content' => $response->getContent(), 'headers' => $response->headers, 'version' => $response->getProtocolVersion(), 'statusCode' => $response->getStatusCode(), 'charset' => $response->getCharset());
 }
开发者ID:mintbridge,项目名称:laravel-cache-filter,代码行数:11,代码来源:ResponseCacheFilter.php

示例11: createContext

 /**
  * @param Response $response
  * @param Request  $request
  *
  * @return array
  */
 protected function createContext(Response $response, Request $request)
 {
     $context = array('response_status_code' => $response->getStatusCode(), 'response_charset' => $response->getCharset(), 'response_date' => $response->getDate(), 'response_etag' => $response->getEtag(), 'response_expires' => $response->getExpires(), 'response_last_modified' => $response->getLastModified(), 'response_max_age' => $response->getMaxAge(), 'response_protocol_version' => $response->getProtocolVersion(), 'response_ttl' => $response->getTtl(), 'response_vary' => $response->getVary(), 'request_method' => $request->getMethod(), 'request_uri' => $request->getRequestUri(), 'request_route' => $request->attributes->get('_route'), 'response_time' => $this->getTime($request), 'response_memory' => $this->getMemory());
     return $context;
 }
开发者ID:Hexanet,项目名称:MonologExtraBundle,代码行数:11,代码来源:ResponseLogger.php


注:本文中的Symfony\Component\HttpFoundation\Response::getCharset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。