Advertisement
Guest User

Untitled

a guest
Dec 29th, 2017
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.87 KB | None | 0 0
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Andreas Fischer <bantu@owncloud.com>
  6. * @author Bart Visscher <bartv@thisnet.nl>
  7. * @author Frank Karlitschek <frank@karlitschek.de>
  8. * @author Lukas Reschke <lukas@statuscode.ch>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Robin Appelman <robin@icewind.nl>
  11. * @author Stefan Weil <sw@weilnetz.de>
  12. * @author Thomas Müller <thomas.mueller@tmit.eu>
  13. * @author Vincent Petry <pvince81@owncloud.com>
  14. *
  15. * @license AGPL-3.0
  16. *
  17. * This code is free software: you can redistribute it and/or modify
  18. * it under the terms of the GNU Affero General Public License, version 3,
  19. * as published by the Free Software Foundation.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU Affero General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU Affero General Public License, version 3,
  27. * along with this program. If not, see <http://www.gnu.org/licenses/>
  28. *
  29. */
  30.  
  31. /**
  32. * Public interface of ownCloud for apps to use.
  33. * Response Class.
  34. *
  35. */
  36.  
  37. // use OCP namespace for all classes that are considered public.
  38. // This means that they should be used by apps instead of the internal ownCloud classes
  39. namespace OCP;
  40.  
  41. /**
  42. * This class provides convenient functions to send the correct http response headers
  43. * @since 4.0.0
  44. * @deprecated 8.1.0 - Use AppFramework controllers instead and modify the response object
  45. */
  46. class Response {
  47. /**
  48. * Enable response caching by sending correct HTTP headers
  49. * @param int $cache_time time to cache the response
  50. * >0 cache time in seconds
  51. * 0 and <0 enable default browser caching
  52. * null cache indefinitely
  53. * @since 4.0.0
  54. */
  55. static public function enableCaching( $cache_time = null ) {
  56. \OC_Response::enableCaching( $cache_time );
  57. }
  58.  
  59. /**
  60. * Checks and set Last-Modified header, when the request matches sends a
  61. * 'not modified' response
  62. * @param string $lastModified time when the response was last modified
  63. * @since 4.0.0
  64. */
  65. static public function setLastModifiedHeader( $lastModified ) {
  66. \OC_Response::setLastModifiedHeader( $lastModified );
  67. }
  68.  
  69. /**
  70. * Sets the content disposition header (with possible workarounds)
  71. * @param string $filename file name
  72. * @param string $type disposition type, either 'attachment' or 'inline'
  73. * @since 7.0.0
  74. */
  75. static public function setContentDispositionHeader( $filename, $type = 'attachment' ) {
  76. \OC_Response::setContentDispositionHeader( $filename, $type );
  77. }
  78.  
  79. /**
  80. * Sets the content length header (with possible workarounds)
  81. * @param string|int|float $length Length to be sent
  82. * @since 8.1.0
  83. */
  84. static public function setContentLengthHeader($length) {
  85. \OC_Response::setContentLengthHeader($length);
  86. }
  87.  
  88. /**
  89. * Disable browser caching
  90. * @see enableCaching with cache_time = 0
  91. * @since 4.0.0
  92. */
  93. static public function disableCaching() {
  94. \OC_Response::disableCaching();
  95. }
  96.  
  97. /**
  98. * Checks and set ETag header, when the request matches sends a
  99. * 'not modified' response
  100. * @param string $etag token to use for modification check
  101. * @since 4.0.0
  102. */
  103. static public function setETagHeader( $etag ) {
  104. \OC_Response::setETagHeader( $etag );
  105. }
  106. /**
  107. * Send file as response, checking and setting caching headers
  108. * @param string $filepath of file to send
  109. * @since 4.0.0
  110. * @deprecated 8.1.0 - Use \OCP\AppFramework\Http\StreamResponse or another AppFramework controller instead
  111. */
  112. static public function sendFile( $filepath ) {
  113. \OC_Response::sendFile( $filepath );
  114. }
  115.  
  116. /**
  117. * Set response expire time
  118. * @param string|\DateTime $expires date-time when the response expires
  119. * string for DateInterval from now
  120. * DateTime object when to expire response
  121. * @since 4.0.0
  122. */
  123. static public function setExpiresHeader( $expires ) {
  124. \OC_Response::setExpiresHeader( $expires );
  125. }
  126.  
  127. /**
  128. * Send redirect response
  129. * @param string $location to redirect to
  130. * @since 4.0.0
  131. */
  132. static public function redirect( $location ) {
  133. \OC_Response::redirect( $location );
  134. }
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement