• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Http\IResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Nette\Http\IResponse的典型用法代码示例。如果您正苦于以下问题:PHP IResponse类的具体用法?PHP IResponse怎么用?PHP IResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: send

 /**
  * Sends response to output.
  * @return void
  */
 public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
 {
     $httpResponse->setContentType($this->contentType);
     $httpResponse->setHeader('Content-Disposition', ($this->forceDownload ? 'attachment' : 'inline') . '; filename="' . $this->name . '"' . '; filename*=utf-8\'\'' . rawurlencode($this->name));
     $length = strlen($this->data);
     /*
     		if ($this->resuming) {
     			$httpResponse->setHeader('Accept-Ranges', 'bytes');
     			if (preg_match('#^bytes=(\d*)-(\d*)\z#', $httpRequest->getHeader('Range'), $matches)) {
     				list(, $start, $end) = $matches;
     				if ($start === '') {
     					$start = max(0, $filesize - $end);
     					$end = $filesize - 1;
     
     				} elseif ($end === '' || $end > $filesize - 1) {
     					$end = $filesize - 1;
     				}
     				if ($end < $start) {
     					$httpResponse->setCode(416); // requested range not satisfiable
     					return;
     				}
     
     				$httpResponse->setCode(206);
     				$httpResponse->setHeader('Content-Range', 'bytes ' . $start . '-' . $end . '/' . $filesize);
     				$length = $end - $start + 1;
     				fseek($handle, $start);
     
     			} else {
     				$httpResponse->setHeader('Content-Range', 'bytes 0-' . ($filesize - 1) . '/' . $filesize);
     			}
     		}*/
     $httpResponse->setHeader('Content-Length', $length);
     echo $this->data;
 }
开发者ID:bkralik,项目名称:BarakIS,代码行数:38,代码来源:DownloadReponse.php


示例2: send

 /**
  * {inheritDoc}
  */
 public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
 {
     $httpResponse->setContentType($this->getContentType(), 'utf-8');
     $httpResponse->setExpiration(FALSE);
     $httpResponse->setCode($this->code);
     echo Nette\Utils\Json::encode($this->getPayload(), Nette\Utils\Json::PRETTY);
 }
开发者ID:ublaboo,项目名称:responses,代码行数:10,代码来源:JsonPrettyResponse.php


示例3: generateImage

 public function generateImage(ImageRequest $request)
 {
     $width = $request->getWidth();
     $height = $request->getHeight();
     $format = $request->getFormat();
     if (!$this->validator->validate($width, $height)) {
         throw new Application\BadRequestException();
     }
     $image = NULL;
     foreach ($this->providers as $provider) {
         $image = $provider->getImage($request);
         if ($image) {
             break;
         }
     }
     if (!$image) {
         $this->httpResponse->setHeader('Content-Type', 'image/jpeg');
         $this->httpResponse->setCode(Http\IResponse::S404_NOT_FOUND);
         exit;
     }
     $destination = $this->wwwDir . '/' . $this->httpRequest->getUrl()->getRelativeUrl();
     $dirname = dirname($destination);
     if (!is_dir($dirname)) {
         $success = @mkdir($dirname, 0777, TRUE);
         if (!$success) {
             throw new Application\BadRequestException();
         }
     }
     $success = $image->save($destination, 90, $format);
     if (!$success) {
         throw new Application\BadRequestException();
     }
     $image->send();
     exit;
 }
开发者ID:kuba1999,项目名称:nette-webimages,代码行数:35,代码来源:Generator.php


示例4: send

 /**
  * @param IRequest $httpRequest
  * @param IResponse $httpResponse
  * @return void
  */
 public function send(IRequest $httpRequest, IResponse $httpResponse)
 {
     $httpResponse->setCode($this->code);
     foreach ($this->headers as $name => $value) {
         $httpResponse->setHeader($name, $value);
     }
     echo (string) $this->getBody();
 }
开发者ID:lookyman,项目名称:nette-oauth2-server,代码行数:13,代码来源:Response.php


示例5: send

 /**
  * @param Nette\Http\IRequest $httpRequest
  * @param Nette\Http\IResponse $httpResponse
  */
 function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
 {
     $response = $this->getResponse();
     $httpResponse->setCode(200);
     $httpResponse->setContentType('text/plain');
     $httpResponse->setHeader('Content-Length', strlen($response));
     echo $response;
 }
开发者ID:minetro,项目名称:mobilni-platby,代码行数:12,代码来源:Response.php


示例6: send

 /**
  * @param Http\IRequest $request
  * @param Http\IResponse $response
  */
 public function send(Http\IRequest $request, Http\IResponse $response)
 {
     $response->setContentType($this->contentType);
     $response->setCode($this->code ?: Http\IResponse::S200_OK);
     $response->setExpiration($this->expiration);
     $response->setHeader('Pragma', $this->expiration ? 'cache' : 'no-cache');
     echo Json::encode($this->data);
 }
开发者ID:dzibma,项目名称:rest-api,代码行数:12,代码来源:JsonResponse.php


示例7: send

 /**
  * {@inheritdoc}
  */
 public function send(IRequest $httpRequest, IResponse $httpResponse)
 {
     $httpResponse->setContentType('text/xml');
     $httpResponse->setExpiration(false);
     $httpResponse->setCode($this->getCode());
     $httpResponse->setHeader('Content-Length', strlen($this->response));
     echo $this->response;
 }
开发者ID:tomaj,项目名称:nette-api,代码行数:11,代码来源:XmlApiResponse.php


示例8: send

 /**
  * Send JSONP response to output
  * @param IRequest $httpRequest
  * @param IResponse $httpResponse
  * @throws \Drahak\Restful\InvalidArgumentException
  */
 public function send(IRequest $httpRequest, IResponse $httpResponse)
 {
     $httpResponse->setContentType($this->contentType ? $this->contentType : 'application/javascript', 'UTF-8');
     $data = array();
     $data['response'] = $this->data;
     $data['status'] = $httpResponse->getCode();
     $data['headers'] = $httpResponse->getHeaders();
     $callback = $httpRequest->getQuery('jsonp') ? Strings::webalize($httpRequest->getQuery('jsonp'), NULL, FALSE) : '';
     echo $callback . '(' . $this->mapper->stringify($data, $this->isPrettyPrint()) . ');';
 }
开发者ID:lucien144,项目名称:Restful,代码行数:16,代码来源:JsonpResponse.php


示例9: send

 /**
  * @param Nette\Http\IRequest $httpRequest
  * @param Nette\Http\IResponse $httpResponse
  * @throws \Nette\Application\BadRequestException
  */
 public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
 {
     $httpResponse->setContentType($this->contentType);
     $httpResponse->setExpiration(FALSE);
     $callback = $httpRequest->getQuery(self::$callbackName);
     if (is_null($callback)) {
         throw new \Nette\Application\BadRequestException("Invalid JSONP request.");
     }
     echo $callback . "(" . Nette\Utils\Json::encode($this->payload) . ")";
 }
开发者ID:frosty22,项目名称:ale,代码行数:15,代码来源:JsonpResponse.php


示例10: send

 /**
  * Sends response to output.
  * @param IRequest   $request
  * @param IResponse  $response
  */
 public function send(IRequest $request, IResponse $response)
 {
     // Set response headers for the file download
     $response->setHeader('Content-Length', $this->stream->getSize());
     $response->setHeader('Content-Type', $this->contentType);
     $response->setHeader('Content-Disposition', 'attachment; filename="' . $this->name . '";');
     while (!$this->stream->eof()) {
         echo $this->stream->read(4000000.0);
     }
     $this->stream->close();
 }
开发者ID:ublaboo,项目名称:responses,代码行数:16,代码来源:PSR7StreamResponse.php


示例11: send

 /**
  * Sends response to output.
  * @return void
  */
 public function send(IRequest $httpRequest, \Nette\Http\IResponse $httpResponse)
 {
     if ($this->error) {
         $this->payload = ['error' => TRUE, 'message' => $this->errorMessage];
     } else {
         $this->payload['error'] = FALSE;
     }
     $httpResponse->setContentType($this->contentType);
     $httpResponse->setExpiration(FALSE);
     echo Json::encode($this->payload);
 }
开发者ID:pogodi,项目名称:OCApi,代码行数:15,代码来源:JsonResponse.php


示例12: send

 /**
  * Sends response to output.
  *
  * @param \Nette\Http\IRequest $httpRequest
  * @param \Nette\Http\IResponse $httpResponse
  */
 public function send(\Nette\Http\IRequest $httpRequest, \Nette\Http\IResponse $httpResponse)
 {
     if (strlen($this->etag)) {
         $httpResponse->setHeader('Etag', $this->etag);
     }
     $httpResponse->setExpiration(\Nette\Http\IResponse::PERMANENT);
     if (($inm = $httpRequest->getHeader('if-none-match')) && $inm == $this->etag) {
         $httpResponse->setCode(\Nette\Http\IResponse::S304_NOT_MODIFIED);
         return;
     }
     $httpResponse->setContentType($this->contentType);
     echo $this->content;
 }
开发者ID:lohini,项目名称:webloader,代码行数:19,代码来源:WebLoaderResponse.php


示例13: send

 function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
 {
     if ($this->isAmfRequest($httpRequest)) {
         $httpResponse->setContentType('application/x-amf');
         $this->manager->sendResponse();
     } else {
         $responses = $this->manager->getResponses();
         if (count($responses) === 1) {
             $responses = array_shift($responses);
         }
         $response = new Nette\Application\Responses\JsonResponse($responses);
         $response->send($httpRequest, $httpResponse);
     }
 }
开发者ID:goodshape,项目名称:nette-amf,代码行数:14,代码来源:FinalResponse.php


示例14: sendStorageFile

 /**
  * Sends chunked response to output.
  *
  * @param \MouseOver\Storage\IStorageFile $storageFile  Storage file
  * @param \Nette\Http\IRequest            $httpRequest  HTTP request
  * @param \Nette\Http\IResponse           $httpResponse HTTP response
  *
  * @return void
  */
 protected function sendStorageFile($storageFile, Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
 {
     $httpResponse->setHeader('Accept-Ranges', 'bytes');
     $reader = $storageFile->getReader();
     if (preg_match('#^bytes=(\\d*)-(\\d*)\\z#', $httpRequest->getHeader('Range'), $matches)) {
         list(, $start, $end) = $matches;
         if ($start === '') {
             $start = null;
         }
         if ($end === '') {
             $end = null;
         }
         try {
             $reader->setRange($start, $end);
         } catch (\InvalidArgumentException $invalidArgumentException) {
             $httpResponse->setCode(416);
             // requested range not satisfiable
             return;
         }
         $httpResponse->setCode(206);
         $httpResponse->setHeader('Content-Range', 'bytes ' . $reader->getRangeStart() . '-' . $reader->getRangeEnd() . '/' . $reader->getFileSize());
         $reader->setRange($start, $end);
         $httpResponse->setHeader('Content-Length', $reader->getLength());
     } else {
         $httpResponse->setHeader('Content-Range', 'bytes 0-' . ($reader->getFileSize() - 1) . '/' . $reader->getFileSize());
         $httpResponse->setHeader('Content-Length', $reader->getLength());
     }
     while ($reader->hasContent()) {
         echo $reader->read();
     }
 }
开发者ID:mouse-over,项目名称:storage,代码行数:40,代码来源:StorageFileResponse.php


示例15: send

 /**
  * Sends response to output.
  * @param Nette\Http\IRequest  $httpRequest
  * @param Nette\Http\IResponse $httpResponse
  */
 function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
 {
     $httpResponse->setContentType('application/pdf');
     $httpResponse->setHeader('Content-Disposition', 'inline; filename="' . basename($this->filePath) . '"');
     $httpResponse->setHeader('Content-Description', 'File Transfer');
     $httpResponse->setHeader('Connection', 'Keep-Alive');
     $httpResponse->setHeader('Expires', '0');
     $httpResponse->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0');
     $httpResponse->setHeader('Pragma', 'public');
     $httpResponse->setHeader('Content-Length', filesize($this->filePath));
     readfile($this->filePath);
 }
开发者ID:klimesf,项目名称:nette-responses,代码行数:17,代码来源:PdfResponse.php


示例16: send

 /**
  * Sends response to output.
  * @param Nette\Http\IRequest $httpRequest
  * @param Nette\Http\IResponse $httpResponse
  * @return void
  */
 public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
 {
     $httpResponse->setContentType($this->contentType);
     $httpResponse->setExpiration(FALSE);
     $response = array();
     $actual_url = $httpRequest->getUrl()->getAbsoluteUrl();
     date_default_timezone_set('UTC');
     //TODO: -1min
     $date = date('YmdHi');
     $hmac = hash_hmac('sha512', $actual_url . $date, 'PRIVATE_KEY');
     //TODO: na základě public key ($api_key)
     if ($this->payload['api_hash'] !== $hmac) {
         $response['err_code'] = 10;
         $response['err_info'] = $this->errors[10];
     }
     echo Nette\Utils\Json::encode($this->payload);
 }
开发者ID:krausv,项目名称:www.zeminem.cz,代码行数:23,代码来源:ApiResponse.php


示例17: send

 /**
  * Sends response to output.
  * @param  Nette\Http\IRequest  $httpRequest
  * @param  Nette\Http\IResponse $httpResponse
  * @return void
  */
 public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
 {
     /**
      * Disable tracy bar
      */
     if (class_exists('\\Tracy\\Debugger') && property_exists('\\Tracy\\Debugger', 'productionMode')) {
         \Tracy\Debugger::$productionMode = TRUE;
     }
     /**
      * Set Content-Type header
      */
     $httpResponse->setContentType($this->contentType, $this->output_encoding);
     /**
      * Set Content-Disposition header
      */
     $httpResponse->setHeader('Content-Disposition', 'attachment' . '; filename="' . $this->name . '"');
     /*. '; filename*=' . $this->output_encoding . '\'\'' . rawurlencode($this->name));*/
     /**
      * Set other headers
      */
     foreach ($this->headers as $key => $value) {
         $httpResponse->setHeader($key, $value);
     }
     if (function_exists('ob_start')) {
         ob_start();
     }
     /**
      * Output data
      */
     if ($this->include_bom && strtolower($this->output_encoding) == 'utf-8') {
         echo "";
     }
     $delimiter = '"' . $this->delimiter . '"';
     foreach ($this->data as $row) {
         if (strtolower($this->output_encoding) == 'utf-8') {
             echo '"' . implode($delimiter, (array) $row) . '"';
         } else {
             echo iconv('UTF-8', $this->output_encoding, '"' . implode($delimiter, (array) $row) . '"');
         }
         echo "\r\n";
     }
     if (function_exists('ob_end_flush')) {
         ob_end_flush();
     }
 }
开发者ID:ublaboo,项目名称:responses,代码行数:51,代码来源:CSVResponse.php


示例18: send

 /**
  * Sends response to output.
  * @return void
  */
 public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
 {
     $httpResponse->setContentType($this->contentType);
     $httpResponse->setHeader('Content-Disposition', ($this->forceDownload ? 'attachment' : 'inline') . '; filename="' . $this->name . '"');
     $output = NULL;
     if ($this->precalculateFileSize) {
         ob_start();
         Nette\Utils\Callback::invokeArgs($this->outputGenerator);
         $output = ob_get_clean();
         $filesize = $length = strlen($output);
     }
     if ($this->resuming && $this->precalculateFileSize) {
         $httpResponse->setHeader('Accept-Ranges', 'bytes');
         if (preg_match('#^bytes=(\\d*)-(\\d*)\\z#', $httpRequest->getHeader('Range'), $matches)) {
             list(, $start, $end) = $matches;
             if ($start === '') {
                 $start = max(0, $filesize - $end);
                 $end = $filesize - 1;
             } elseif ($end === '' || $end > $filesize - 1) {
                 $end = $filesize - 1;
             }
             if ($end < $start) {
                 $httpResponse->setCode(416);
                 // requested range not satisfiable
                 return;
             }
             $httpResponse->setCode(206);
             $httpResponse->setHeader('Content-Range', 'bytes ' . $start . '-' . $end . '/' . $filesize);
             $length = $end - $start + 1;
         } else {
             $httpResponse->setHeader('Content-Range', 'bytes 0-' . ($filesize - 1) . '/' . $filesize);
         }
     }
     if ($this->precalculateFileSize) {
         $httpResponse->setHeader('Content-Length', $length);
     }
     if (isset($start)) {
         echo substr($output, $start, $length);
     } elseif (isset($output)) {
         echo $output;
     } else {
         Nette\Utils\Callback::invoke($this->outputGenerator);
     }
 }
开发者ID:instante,项目名称:responses,代码行数:48,代码来源:VirtualFileResponse.php


示例19: __invoke

 public function __invoke($application, $response)
 {
     if ($response instanceof JsonResponse && ($payload = $response->getPayload()) instanceof \stdClass) {
         if ($this->forwardHasHappened && !isset($payload->redirect)) {
             $payload->url = $application->getPresenter()->link('this');
         }
         $this->httpResponse->addHeader('Vary', 'X-Requested-With');
     }
 }
开发者ID:svobodni,项目名称:web,代码行数:9,代码来源:OnResponseHandler.php


示例20: checkAllowedMethods

 /**
  * Check allowed methods
  *
  * @throws BadRequestException If method is not supported but another one can be used
  */
 protected function checkAllowedMethods()
 {
     $availableMethods = $this->methods->getOptions($this->request->getUrl());
     if (!$availableMethods || in_array($this->request->method, $availableMethods)) {
         return;
     }
     $allow = implode(', ', $availableMethods);
     $this->response->setHeader('Allow', $allow);
     throw BadRequestException::methodNotSupported('Method not supported. Available methods: ' . $allow);
 }
开发者ID:lucien144,项目名称:Restful,代码行数:15,代码来源:MethodHandler.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Http\Session类代码示例发布时间:2022-05-23
下一篇:
PHP Http\IRequest类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap