本文整理汇总了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)));
}
示例2: sendHeaders
/**
* @return $this|Response
*/
public function sendHeaders()
{
if ($this->mustSendHeaders()) {
return parent::sendHeaders();
}
return $this;
}
示例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());
}
示例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()));
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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));
}
示例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);
}
示例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();
}
示例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));
}
示例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);
}
示例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;
}
示例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;
}