This repository was archived by the owner on Jan 29, 2020. It is now read-only.
{"payload":{"allShortcutsEnabled":false,"fileTree":{"src":{"items":[{"name":"Exception","path":"src/Exception","contentType":"directory"},{"name":"Request","path":"src/Request","contentType":"directory"},{"name":"Response","path":"src/Response","contentType":"directory"},{"name":"functions","path":"src/functions","contentType":"directory"},{"name":"AbstractSerializer.php","path":"src/AbstractSerializer.php","contentType":"file"},{"name":"CallbackStream.php","path":"src/CallbackStream.php","contentType":"file"},{"name":"HeaderSecurity.php","path":"src/HeaderSecurity.php","contentType":"file"},{"name":"MessageTrait.php","path":"src/MessageTrait.php","contentType":"file"},{"name":"PhpInputStream.php","path":"src/PhpInputStream.php","contentType":"file"},{"name":"RelativeStream.php","path":"src/RelativeStream.php","contentType":"file"},{"name":"Request.php","path":"src/Request.php","contentType":"file"},{"name":"RequestFactory.php","path":"src/RequestFactory.php","contentType":"file"},{"name":"RequestTrait.php","path":"src/RequestTrait.php","contentType":"file"},{"name":"Response.php","path":"src/Response.php","contentType":"file"},{"name":"ResponseFactory.php","path":"src/ResponseFactory.php","contentType":"file"},{"name":"ServerRequest.php","path":"src/ServerRequest.php","contentType":"file"},{"name":"ServerRequestFactory.php","path":"src/ServerRequestFactory.php","contentType":"file"},{"name":"Stream.php","path":"src/Stream.php","contentType":"file"},{"name":"StreamFactory.php","path":"src/StreamFactory.php","contentType":"file"},{"name":"UploadedFile.php","path":"src/UploadedFile.php","contentType":"file"},{"name":"UploadedFileFactory.php","path":"src/UploadedFileFactory.php","contentType":"file"},{"name":"Uri.php","path":"src/Uri.php","contentType":"file"},{"name":"UriFactory.php","path":"src/UriFactory.php","contentType":"file"}],"totalCount":23},"":{"items":[{"name":"docs","path":"docs","contentType":"directory"},{"name":"src","path":"src","contentType":"directory"},{"name":"test","path":"test","contentType":"directory"},{"name":".coveralls.yml","path":".coveralls.yml","contentType":"file"},{"name":".gitattributes","path":".gitattributes","contentType":"file"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".scrutinizer.yml","path":".scrutinizer.yml","contentType":"file"},{"name":".travis.yml","path":".travis.yml","contentType":"file"},{"name":"CHANGELOG.md","path":"CHANGELOG.md","contentType":"file"},{"name":"LICENSE.md","path":"LICENSE.md","contentType":"file"},{"name":"README.md","path":"README.md","contentType":"file"},{"name":"composer.json","path":"composer.json","contentType":"file"},{"name":"composer.lock","path":"composer.lock","contentType":"file"},{"name":"mkdocs.yml","path":"mkdocs.yml","contentType":"file"},{"name":"phpcs.xml","path":"phpcs.xml","contentType":"file"},{"name":"phpunit.xml.dist","path":"phpunit.xml.dist","contentType":"file"}],"totalCount":16}},"fileTreeProcessingTime":27.759801,"foldersToFetch":[],"incompleteFileTree":false,"repo":{"id":36025360,"defaultBranch":"master","name":"zend-diactoros","ownerLogin":"zendframework","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2015-05-21T16:48:53.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/296074?v=4","public":true,"private":false,"isOrgOwned":true},"codeLineWrapEnabled":false,"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"master","listCacheKey":"v0:1538077725.0","canEdit":false,"refType":"branch","currentOid":"5a0835b9dc6d58fb97000893d41a3309f2d0447e"},"path":"src/Response.php","currentUser":null,"blob":{"rawLines":["\u003c?php","/**"," * @see https://github.com/zendframework/zend-diactoros for the canonical source repository"," * @copyright Copyright (c) 2015-2018 Zend Technologies USA Inc. (http://www.zend.com)"," * @license https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License"," */","","declare(strict_types=1);","","namespace Zend\\Diactoros;","","use Psr\\Http\\Message\\ResponseInterface;","use Psr\\Http\\Message\\StreamInterface;","","use function gettype;","use function is_float;","use function is_numeric;","use function is_scalar;","use function sprintf;","","/**"," * HTTP response encapsulation."," *"," * Responses are considered immutable; all methods that might change state are"," * implemented such that they retain the internal state of the current"," * message and return a new instance that contains the changed state."," */","class Response implements ResponseInterface","{"," use MessageTrait;",""," const MIN_STATUS_CODE_VALUE = 100;"," const MAX_STATUS_CODE_VALUE = 599;",""," /**"," * Map of standard HTTP status code/reason phrases"," *"," * @var array"," */"," private $phrases = ["," // INFORMATIONAL CODES"," 100 =\u003e 'Continue',"," 101 =\u003e 'Switching Protocols',"," 102 =\u003e 'Processing',"," 103 =\u003e 'Early Hints',"," // SUCCESS CODES"," 200 =\u003e 'OK',"," 201 =\u003e 'Created',"," 202 =\u003e 'Accepted',"," 203 =\u003e 'Non-Authoritative Information',"," 204 =\u003e 'No Content',"," 205 =\u003e 'Reset Content',"," 206 =\u003e 'Partial Content',"," 207 =\u003e 'Multi-Status',"," 208 =\u003e 'Already Reported',"," 226 =\u003e 'IM Used',"," // REDIRECTION CODES"," 300 =\u003e 'Multiple Choices',"," 301 =\u003e 'Moved Permanently',"," 302 =\u003e 'Found',"," 303 =\u003e 'See Other',"," 304 =\u003e 'Not Modified',"," 305 =\u003e 'Use Proxy',"," 306 =\u003e 'Switch Proxy', // Deprecated to 306 =\u003e '(Unused)'"," 307 =\u003e 'Temporary Redirect',"," 308 =\u003e 'Permanent Redirect',"," // CLIENT ERROR"," 400 =\u003e 'Bad Request',"," 401 =\u003e 'Unauthorized',"," 402 =\u003e 'Payment Required',"," 403 =\u003e 'Forbidden',"," 404 =\u003e 'Not Found',"," 405 =\u003e 'Method Not Allowed',"," 406 =\u003e 'Not Acceptable',"," 407 =\u003e 'Proxy Authentication Required',"," 408 =\u003e 'Request Timeout',"," 409 =\u003e 'Conflict',"," 410 =\u003e 'Gone',"," 411 =\u003e 'Length Required',"," 412 =\u003e 'Precondition Failed',"," 413 =\u003e 'Payload Too Large',"," 414 =\u003e 'URI Too Long',"," 415 =\u003e 'Unsupported Media Type',"," 416 =\u003e 'Range Not Satisfiable',"," 417 =\u003e 'Expectation Failed',"," 418 =\u003e 'I\\'m a teapot',"," 421 =\u003e 'Misdirected Request',"," 422 =\u003e 'Unprocessable Entity',"," 423 =\u003e 'Locked',"," 424 =\u003e 'Failed Dependency',"," 425 =\u003e 'Too Early',"," 426 =\u003e 'Upgrade Required',"," 428 =\u003e 'Precondition Required',"," 429 =\u003e 'Too Many Requests',"," 431 =\u003e 'Request Header Fields Too Large',"," 444 =\u003e 'Connection Closed Without Response',"," 451 =\u003e 'Unavailable For Legal Reasons',"," // SERVER ERROR"," 499 =\u003e 'Client Closed Request',"," 500 =\u003e 'Internal Server Error',"," 501 =\u003e 'Not Implemented',"," 502 =\u003e 'Bad Gateway',"," 503 =\u003e 'Service Unavailable',"," 504 =\u003e 'Gateway Timeout',"," 505 =\u003e 'HTTP Version Not Supported',"," 506 =\u003e 'Variant Also Negotiates',"," 507 =\u003e 'Insufficient Storage',"," 508 =\u003e 'Loop Detected',"," 510 =\u003e 'Not Extended',"," 511 =\u003e 'Network Authentication Required',"," 599 =\u003e 'Network Connect Timeout Error',"," ];",""," /**"," * @var string"," */"," private $reasonPhrase;",""," /**"," * @var int"," */"," private $statusCode;",""," /**"," * @param string|resource|StreamInterface $body Stream identifier and/or actual stream resource"," * @param int $status Status code for the response, if any."," * @param array $headers Headers for the response, if any."," * @throws Exception\\InvalidArgumentException on any invalid element."," */"," public function __construct($body = 'php://memory', int $status = 200, array $headers = [])"," {"," $this-\u003esetStatusCode($status);"," $this-\u003estream = $this-\u003egetStream($body, 'wb+');"," $this-\u003esetHeaders($headers);"," }",""," /**"," * {@inheritdoc}"," */"," public function getStatusCode() : int"," {"," return $this-\u003estatusCode;"," }",""," /**"," * {@inheritdoc}"," */"," public function getReasonPhrase() : string"," {"," return $this-\u003ereasonPhrase;"," }",""," /**"," * {@inheritdoc}"," */"," public function withStatus($code, $reasonPhrase = '') : Response"," {"," $new = clone $this;"," $new-\u003esetStatusCode($code, $reasonPhrase);"," return $new;"," }",""," /**"," * Set a valid status code."," *"," * @param int $code"," * @param string $reasonPhrase"," * @throws Exception\\InvalidArgumentException on an invalid status code."," */"," private function setStatusCode($code, $reasonPhrase = '') : void"," {"," if (! is_numeric($code)"," || is_float($code)"," || $code \u003c static::MIN_STATUS_CODE_VALUE"," || $code \u003e static::MAX_STATUS_CODE_VALUE"," ) {"," throw new Exception\\InvalidArgumentException(sprintf("," 'Invalid status code \"%s\"; must be an integer between %d and %d, inclusive',"," is_scalar($code) ? $code : gettype($code),"," static::MIN_STATUS_CODE_VALUE,"," static::MAX_STATUS_CODE_VALUE"," ));"," }",""," if (! is_string($reasonPhrase)) {"," throw new Exception\\InvalidArgumentException(sprintf("," 'Unsupported response reason phrase; must be a string, received %s',"," is_object($reasonPhrase) ? get_class($reasonPhrase) : gettype($reasonPhrase)"," ));"," }",""," if ($reasonPhrase === '' \u0026\u0026 isset($this-\u003ephrases[$code])) {"," $reasonPhrase = $this-\u003ephrases[$code];"," }",""," $this-\u003ereasonPhrase = $reasonPhrase;"," $this-\u003estatusCode = (int) $code;"," }","}"],"stylingDirectives":null,"colorizedLines":null,"csv":null,"csvError":null,"dependabotInfo":{"showConfigurationBanner":false,"configFilePath":null,"networkDependabotPath":"/zendframework/zend-diactoros/network/updates","dismissConfigurationNoticePath":"/settings/dismiss-notice/dependabot_configuration_notice","configurationNoticeDismissed":null},"displayName":"Response.php","displayUrl":"https://github.com/zendframework/zend-diactoros/blob/master/src/Response.php?raw=true","headerInfo":{"blobSize":"5.89 KB","deleteTooltip":"You must be signed in to make or propose changes","editTooltip":"You must be signed in to make or propose changes","ghDesktopPath":"https://desktop.github.com","isGitLfs":false,"onBranch":true,"shortPath":"92b42d8","siteNavLoginPath":"/login?return_to=https%3A%2F%2Fgithub.com%2Fzendframework%2Fzend-diactoros%2Fblob%2Fmaster%2Fsrc%2FResponse.php","isCSV":false,"isRichtext":false,"toc":null,"lineInfo":{"truncatedLoc":"199","truncatedSloc":"182"},"mode":"file"},"image":false,"isCodeownersFile":null,"isPlain":false,"isValidLegacyIssueTemplate":false,"issueTemplate":null,"discussionTemplate":null,"language":"PHP","languageID":272,"large":false,"planSupportInfo":{"repoIsFork":null,"repoOwnedByCurrentUser":null,"requestFullPath":"/zendframework/zend-diactoros/blob/master/src/Response.php","showFreeOrgGatedFeatureMessage":null,"showPlanSupportBanner":null,"upgradeDataAttributes":null,"upgradePath":null},"publishBannersInfo":{"dismissActionNoticePath":"/settings/dismiss-notice/publish_action_from_dockerfile","releasePath":"/zendframework/zend-diactoros/releases/new?marketplace=true","showPublishActionBanner":false},"rawBlobUrl":"https://github.com/zendframework/zend-diactoros/raw/refs/heads/master/src/Response.php","renderImageOrRaw":false,"richText":null,"renderedFileInfo":null,"shortPath":null,"symbolsEnabled":true,"tabSize":8,"topBannersInfo":{"overridingGlobalFundingFile":false,"globalPreferredFundingPath":null,"showInvalidCitationWarning":false,"citationHelpUrl":"https://docs.github.com/github/creating-cloning-and-archiving-repositories/creating-a-repository-on-github/about-citation-files","actionsOnboardingTip":null},"truncated":false,"viewable":true,"workflowRedirectUrl":null,"symbols":{"timed_out":false,"not_analyzed":false,"symbols":[{"name":"Zend\\Diactoros","kind":"module","ident_start":337,"ident_end":351,"extent_start":327,"extent_end":352,"fully_qualified_name":"Zend\\Diactoros","ident_utf16":{"start":{"line_number":9,"utf16_col":10},"end":{"line_number":9,"utf16_col":24}},"extent_utf16":{"start":{"line_number":9,"utf16_col":0},"end":{"line_number":9,"utf16_col":25}}},{"name":"Response","kind":"class","ident_start":819,"ident_end":827,"extent_start":813,"extent_end":6030,"fully_qualified_name":"Response","ident_utf16":{"start":{"line_number":27,"utf16_col":6},"end":{"line_number":27,"utf16_col":14}},"extent_utf16":{"start":{"line_number":27,"utf16_col":0},"end":{"line_number":198,"utf16_col":1}}},{"name":"ResponseInterface","kind":"implementation","ident_start":839,"ident_end":856,"extent_start":828,"extent_end":856,"fully_qualified_name":"Response.ResponseInterface","ident_utf16":{"start":{"line_number":27,"utf16_col":26},"end":{"line_number":27,"utf16_col":43}},"extent_utf16":{"start":{"line_number":27,"utf16_col":15},"end":{"line_number":27,"utf16_col":43}}},{"name":"phrases","kind":"field","ident_start":1070,"ident_end":1077,"extent_start":1061,"extent_end":3550,"fully_qualified_name":"Response.phrases","ident_utf16":{"start":{"line_number":39,"utf16_col":13},"end":{"line_number":39,"utf16_col":20}},"extent_utf16":{"start":{"line_number":39,"utf16_col":4},"end":{"line_number":111,"utf16_col":6}}},{"name":"reasonPhrase","kind":"field","ident_start":3600,"ident_end":3612,"extent_start":3591,"extent_end":3613,"fully_qualified_name":"Response.reasonPhrase","ident_utf16":{"start":{"line_number":116,"utf16_col":13},"end":{"line_number":116,"utf16_col":25}},"extent_utf16":{"start":{"line_number":116,"utf16_col":4},"end":{"line_number":116,"utf16_col":26}}},{"name":"statusCode","kind":"field","ident_start":3660,"ident_end":3670,"extent_start":3651,"extent_end":3671,"fully_qualified_name":"Response.statusCode","ident_utf16":{"start":{"line_number":121,"utf16_col":13},"end":{"line_number":121,"utf16_col":23}},"extent_utf16":{"start":{"line_number":121,"utf16_col":4},"end":{"line_number":121,"utf16_col":24}}},{"name":"__construct","kind":"method","ident_start":4010,"ident_end":4021,"extent_start":3994,"extent_end":4229,"fully_qualified_name":"Response.__construct","ident_utf16":{"start":{"line_number":129,"utf16_col":20},"end":{"line_number":129,"utf16_col":31}},"extent_utf16":{"start":{"line_number":129,"utf16_col":4},"end":{"line_number":134,"utf16_col":5}}},{"name":"getStatusCode","kind":"method","ident_start":4288,"ident_end":4301,"extent_start":4272,"extent_end":4355,"fully_qualified_name":"Response.getStatusCode","ident_utf16":{"start":{"line_number":139,"utf16_col":20},"end":{"line_number":139,"utf16_col":33}},"extent_utf16":{"start":{"line_number":139,"utf16_col":4},"end":{"line_number":142,"utf16_col":5}}},{"name":"getReasonPhrase","kind":"method","ident_start":4414,"ident_end":4429,"extent_start":4398,"extent_end":4488,"fully_qualified_name":"Response.getReasonPhrase","ident_utf16":{"start":{"line_number":147,"utf16_col":20},"end":{"line_number":147,"utf16_col":35}},"extent_utf16":{"start":{"line_number":147,"utf16_col":4},"end":{"line_number":150,"utf16_col":5}}},{"name":"withStatus","kind":"method","ident_start":4547,"ident_end":4557,"extent_start":4531,"extent_end":4707,"fully_qualified_name":"Response.withStatus","ident_utf16":{"start":{"line_number":155,"utf16_col":20},"end":{"line_number":155,"utf16_col":30}},"extent_utf16":{"start":{"line_number":155,"utf16_col":4},"end":{"line_number":160,"utf16_col":5}}},{"name":"setStatusCode","kind":"method","ident_start":4921,"ident_end":4934,"extent_start":4904,"extent_end":6028,"fully_qualified_name":"Response.setStatusCode","ident_utf16":{"start":{"line_number":169,"utf16_col":21},"end":{"line_number":169,"utf16_col":34}},"extent_utf16":{"start":{"line_number":169,"utf16_col":4},"end":{"line_number":197,"utf16_col":5}}}]}},"copilotInfo":null,"copilotAccessAllowed":false,"modelsAccessAllowed":false,"modelsRepoIntegrationEnabled":false,"csrf_tokens":{"/zendframework/zend-diactoros/branches":{"post":"MnqafIUsjl0NGe3OQiMsOYDmXjQ0bv7zcRBCOP4gTghOPYQhiWWnV54zr8j_DdOgtYT81xmu00VdfvjvjB675g"},"/repos/preferences":{"post":"mHdfEczD1RjtOAATwZzsXGYIbF8I3frZ9PVJgGmTRoYJWCBJ9M_FkJ7L-vUzuqiIHddtlKaQ4x3plIEXNs6qzQ"}}},"title":"zend-diactoros/src/Response.php at master · zendframework/zend-diactoros","appPayload":{"helpUrl":"https://docs.github.com","findFileWorkerPath":"/assets-cdn/worker/find-file-worker-7d7eb7c71814.js","findInFileWorkerPath":"/assets-cdn/worker/find-in-file-worker-1ae9fa256942.js","githubDevUrl":null,"enabled_features":{"code_nav_ui_events":false,"react_blob_overlay":false,"accessible_code_button":true,"github_models_repo_integration":false}}}
You can’t perform that action at this time.