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


PHP Response::sendHeaders方法代码示例

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


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

示例1: frontendResetAction

 public function frontendResetAction($id = false)
 {
     $response = new Response();
     $response->headers->setCookie(new Cookie("subscriber_id", false));
     $response->sendHeaders();
     return $this->redirect($this->generateUrl('subscriber_frondend_submit', array('id' => $id)));
 }
开发者ID:r-vetter,项目名称:Christian-holidays-ticket-system,代码行数:7,代码来源:SubscriberController.php

示例2: sendHeaders

 /**
  * @return $this|Response
  */
 public function sendHeaders()
 {
     if ($this->mustSendHeaders()) {
         return parent::sendHeaders();
     }
     return $this;
 }
开发者ID:miguelpedregosa,项目名称:huruk,代码行数:10,代码来源:Responder.php

示例3: Response

 /**
  * @param string $content
  * @param int $status
  * @param array $headers
  * @return Response
  */
 function response_plain($content, $status = Response::HTTP_OK, array $headers = [])
 {
     // We have to do a little trick and do not allow WHMCS to sent all it's content.
     $response = new Response($content, $status, $headers);
     $response->sendHeaders();
     die($response->getContent());
 }
开发者ID:4ernovm,项目名称:whmcs-foundation,代码行数:13,代码来源:helper_functions.php

示例4: showQuestionAction

 /**
  * @Route("/question/{id}", name="question")
  */
 public function showQuestionAction($id = null, Request $request)
 {
     $session = new Session();
     $notice = $session->getFlashBag();
     $query = $this->getDoctrine()->getRepository('AppBundle:Question');
     $size = $query->size();
     $response = new Response();
     if (!$id) {
         $response->headers->clearCookie('checked');
         $response->sendHeaders();
         return $this->redirect($this->generateUrl('question', array('id' => mt_rand(1, $size))));
     }
     $question = $query->find($id);
     $query = $this->getDoctrine()->getRepository('AppBundle:Choice');
     $form = $this->createForm(new QuestionType($question, $query, $size));
     $form->handleRequest($request);
     if ($form->get('next')->isClicked()) {
         $id = $form->get('questionId')->getViewData() ? $form->get('questionId')->getViewData() : mt_rand(1, $size);
         return $this->redirect($this->generateUrl('question', array('id' => $id)));
     }
     if ($form->isSubmitted() && $form->isValid()) {
         $currentChoices = $form["choices"]->getViewData();
         if (is_array($currentChoices)) {
             $currentChoices = array_map('current', $currentChoices);
         } else {
             $currentChoices = $currentChoices ? array($currentChoices->getId()) : '';
         }
         $rightChoices = $query->getQuestionChoices($id);
         !array_diff($rightChoices, $currentChoices) ? $notice->add('success', "Congratulation, it's a right answer!") : $notice->add('error', "Sorry, this is wrong answer.");
         return $this->redirect($this->generateUrl('question', array('id' => $id)));
     }
     $imageHelper = new Image($question, $this->get('kernel'));
     return $this->render('default/questions.html.twig', array('question' => $question, 'form' => $form->createView(), 'image_path' => $imageHelper->getImageAssetPath()));
 }
开发者ID:repsa,项目名称:quiz,代码行数:37,代码来源:DefaultController.php

示例5: setGuidCookie

 public function setGuidCookie($arr)
 {
     $gInfo = base64_encode(serialize($arr));
     $response = new Response();
     $expiration = time() + 3600 * 24 * 365 * 5;
     $response->headers->setCookie(new Cookie(self::GUID_COOKIE_INFO, $gInfo, $expiration));
     $response->sendHeaders();
 }
开发者ID:jwoods,项目名称:CE_27,代码行数:8,代码来源:UserService.php

示例6: sendHeaders

 /**
  *  send the http response headers
  *  
  *  overrides the parent to not attempt to send the headers if there was output before this
  *  method was called
  *  
  *  @since  6-30-11         
  */
 public function sendHeaders()
 {
     // canary...
     if (headers_sent()) {
         return;
     }
     //if
     return parent::sendHeaders();
 }
开发者ID:Jaymon,项目名称:Montage,代码行数:17,代码来源:Response.php

示例7: sendHeaders

 /**
  * {@inheritdoc}
  */
 public function sendHeaders()
 {
     if ($this->config->get('image_captcha_file_format') == IMAGE_CAPTCHA_FILE_FORMAT_JPG) {
         $this->headers->set('content-type', 'image/jpeg');
     } else {
         $this->headers->set('content-type', 'image/png');
     }
     return parent::sendHeaders();
 }
开发者ID:Wylbur,项目名称:gj,代码行数:12,代码来源:CaptchaImageResponse.php

示例8: storeUserInfo

 /**
  * @param array $userInfo
  */
 private function storeUserInfo($userInfo)
 {
     $extension = $this->get('app.twig_extension');
     $sessionId = $extension->generateSessionId();
     $extension->createSession($sessionId, $userInfo);
     $response = new Response();
     $expired = time() + 86400 * 30;
     $response->headers->setCookie(new Cookie('session_id', $sessionId, $expired));
     $response->sendHeaders();
 }
开发者ID:squarer,项目名称:symfony3-demo,代码行数:13,代码来源:LoginController.php

示例9: downloadAction

 /**
  * @Route("/download", name="filesearch_download")
  */
 public function downloadAction(Request $request)
 {
     $filePath = $request->get('path', null);
     $response = new Response();
     $response->headers->set('Cache-Control', 'private');
     $response->headers->set('Content-type', mime_content_type($filePath));
     $response->headers->set('Content-Disposition', 'attachment; filename="' . basename($filePath) . '";');
     $response->headers->set('Content-length', filesize($filePath));
     $response->sendHeaders();
     return $response->setContent(file_get_contents($filePath));
 }
开发者ID:deoliveiralucas,项目名称:file-search-bundle,代码行数:14,代码来源:SearchController.php

示例10: testSendHeaders

 public function testSendHeaders()
 {
     $response = new Response();
     $headers = $response->sendHeaders();
     $this->assertObjectHasAttribute('headers', $headers);
     $this->assertObjectHasAttribute('content', $headers);
     $this->assertObjectHasAttribute('version', $headers);
     $this->assertObjectHasAttribute('statusCode', $headers);
     $this->assertObjectHasAttribute('statusText', $headers);
     $this->assertObjectHasAttribute('charset', $headers);
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:11,代码来源:ResponseTest.php

示例11: loadAction

 /**
  * @Route("/download/{filename}/{file}", name="app_download")
  * @Route("/load/{filename}/{file}", name="app_load")
  * @ParamConverter("file", converter="file_converter")
  * @Method("GET")
  * @param string $filename
  * @param \SplFileObject $file
  * @return Response
  */
 public function loadAction($filename, \SplFileObject $file)
 {
     $response = new Response($file->fpassthru());
     $response->headers->set('Content-Type', 'octet/stream');
     $response->headers->set('Content-disposition', 'attachment; filename="' . $filename . '.' . $file->getExtension() . '";"');
     $response->headers->set('Content-Length', $file->getSize());
     $response->headers->set('Cache-Control', 'max-age=31536000, public');
     // 1 year
     $response->sendHeaders();
     return $response->send();
 }
开发者ID:zhooravell,项目名称:box-songs.com,代码行数:20,代码来源:AudioController.php

示例12: indexAction

 public function indexAction($id = false, Request $request)
 {
     $ticket = $this->getDoctrine()->getRepository('TicketBundle:Ticket')->findOneBy(array('external' => $id));
     if ($ticket == null) {
         return $this->redirect($this->generateUrl('ticket_edit', array('id' => $id)));
     }
     $items = $ticket->getSubscribers();
     $response = new Response();
     $response->headers->setCookie(new Cookie("ticket_id", $id));
     $response->sendHeaders();
     return $this->render('TicketBundle:Ticket:index.html.twig', array('items' => $items, 'ticket' => $ticket));
 }
开发者ID:r-vetter,项目名称:Christian-holidays-ticket-system,代码行数:12,代码来源:TicketController.php

示例13: getFileAction

 public function getFileAction($fileName)
 {
     $filepath = $this->getFolderPath() . $fileName . '.pdf';
     $response = new Response();
     $response->headers->set('Cache-Control', 'private');
     $response->headers->set('Content-type', mime_content_type($filepath));
     $response->headers->set('Content-Disposition', 'attachment; filename="' . basename($filepath) . '";');
     $response->headers->set('Content-length', filesize($filepath));
     $response->sendHeaders();
     $fileContent = readfile($filepath);
     unlink($filepath);
     return $response->setContent($fileContent);
 }
开发者ID:eduardocasas,项目名称:Respira-Madrid,代码行数:13,代码来源:DefaultController.php

示例14: indexAction

 /**
  * @Route("/attachment/{id}", name="attachment_download")
  * @Method({"GET", "POST"})
  */
 public function indexAction(Request $request, $id)
 {
     $em = $this->getDoctrine()->getManager();
     $att = $em->getRepository('oGooseBundle:Attachment')->find($id);
     $filename = $att->getFilename();
     $fullPath = '../media/attachments/' . $filename;
     $response = new Response();
     $response->headers->set('Cache-Control', 'private');
     $response->headers->set('Content-Type', mime_content_type($fullPath) . '; charset=utf-8');
     $response->headers->set('Content-Disposition', 'attachment;filename="' . $filename . '"');
     $response->sendHeaders();
     $response->setContent(readfile($fullPath));
     return $response;
 }
开发者ID:CodeathonURV,项目名称:CodeathonURV2016_OpenURV,代码行数:18,代码来源:AttachmentController.php

示例15: attachmentDownloadAction

 /**
  * @ApiDoc(
  *  description="Attachment download.",
  *  tags={"file"},
  *  requirements={
  *      {
  *          "name"="id",
  *          "dataType"="integer",
  *          "description"="attachment id"
  *      }
  *  },
  *  parameters={
  *      {"name"="id", "dataType"="integer", "required"=true, "description"="attachment id"}
  *  }
  * )
  * 
  * @Route("/attachment/{id}", name="index_attachment_download")
  * @Method("GET")
  */
 public function attachmentDownloadAction($id)
 {
     $em = $this->getDoctrine()->getManager();
     $attachment = $em->getRepository('APPAnswersBundle:Attachment')->find($id);
     $response = new Response();
     $response->headers->set('Cache-Control', 'private');
     $response->headers->set('Content-type', $attachment->getMimeType());
     $response->headers->set('Content-Disposition', 'inline; filename="' . $attachment->getOriginalFilename() . '";');
     $response->headers->set('Content-length', $attachment->getSize());
     $response->sendHeaders();
     $file = $attachment->getSystemPath() . $attachment->getSystemFilename();
     $response->setContent(readfile($file));
     return $response;
 }
开发者ID:RafalStrab,项目名称:answers_test,代码行数:33,代码来源:DefaultController.php


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