Source for file IHttpResponse.php

Documentation is available at IHttpResponse.php

  1. 1: <?php
  2. 2:  
  3. 3: /**
  4. 4:  * Nette Framework
  5. 5:  *
  6. 6:  * Copyright (c) 2004, 2009 David Grudl (http://davidgrudl.com)
  7. 7:  *
  8. 8:  * This source file is subject to the "Nette license" that is bundled
  9. 9:  * with this package in the file license.txt.
  10. 10:  *
  11. 11:  * For more information please see https://nette.org
  12. 12:  *
  13. 13:  * @copyright  Copyright (c) 2004, 2009 David Grudl
  14. 14:  * @license    https://nette.org/license  Nette license
  15. 15:  * @link       https://nette.org
  16. 16:  * @category   Nette
  17. 17:  * @package    Nette\Web
  18. 18:  * @version    $Id$
  19. 19:  */
  20. 20:  
  21. 21:  
  22. 22:  
  23. 23: /**
  24. 24:  * IHttpResponse interface.
  25. 25:  *
  26. 26:  * @author     David Grudl
  27. 27:  * @copyright  Copyright (c) 2004, 2009 David Grudl
  28. 28:  * @package    Nette\Web
  29. 29:  */
  30. 30: interface IHttpResponse
  31. 31: {
  32. 32:     /** @var int cookie expiration: forever (23.1.2037) */
  33. 33:     const PERMANENT 2116333333;
  34. 34:  
  35. 35:     /** @var int cookie expiration: until the browser is closed */
  36. 36:     const BROWSER 0;
  37. 37:  
  38. 38:     /**#@+ HTTP 1.1 response code */
  39. 39:     const
  40. 40:         S200_OK 200,
  41. 41:         S204_NO_CONTENT 204,
  42. 42:         S300_MULTIPLE_CHOICES 300,
  43. 43:         S301_MOVED_PERMANENTLY 301,
  44. 44:         S302_FOUND 302,
  45. 45:         S303_SEE_OTHER 303,
  46. 46:         S303_POST_GET 303,
  47. 47:         S304_NOT_MODIFIED 304,
  48. 48:         S307_TEMPORARY_REDIRECT307,
  49. 49:         S400_BAD_REQUEST 400,
  50. 50:         S401_UNAUTHORIZED 401,
  51. 51:         S403_FORBIDDEN 403,
  52. 52:         S404_NOT_FOUND 404,
  53. 53:         S410_GONE 410,
  54. 54:         S500_INTERNAL_SERVER_ERROR 500,
  55. 55:         S501_NOT_IMPLEMENTED 501,
  56. 56:         S503_SERVICE_UNAVAILABLE 503;
  57. 57:     /**#@-*/
  58. 58:  
  59. 59:     /**
  60. 60:      * Sets HTTP response code.
  61. 61:      * @param  int 
  62. 62:      * @return bool 
  63. 63:      */
  64. 64:     function setCode($code);
  65. 65:  
  66. 66:     /**
  67. 67:      * Returns HTTP response code.
  68. 68:      * @return int 
  69. 69:      */
  70. 70:     function getCode();
  71. 71:  
  72. 72:     /**
  73. 73:      * Sends a HTTP header and replaces a previous one.
  74. 74:      * @param  string  header name
  75. 75:      * @param  string  header value
  76. 76:      * @return void 
  77. 77:      */
  78. 78:     function setHeader($name$value);
  79. 79:  
  80. 80:     /**
  81. 81:      * Adds HTTP header.
  82. 82:      * @param  string  header name
  83. 83:      * @param  string  header value
  84. 84:      * @return void 
  85. 85:      */
  86. 86:     function addHeader($name$value);
  87. 87:  
  88. 88:     /**
  89. 89:      * Sends a Content-type HTTP header.
  90. 90:      * @param  string  mime-type
  91. 91:      * @param  string  charset
  92. 92:      * @return void 
  93. 93:      */
  94. 94:     function setContentType($type$charset NULL);
  95. 95:  
  96. 96:     /**
  97. 97:      * Redirects to a new URL.
  98. 98:      * @param  string  URL
  99. 99:      * @param  int     HTTP code
  100. 100:      * @return void 
  101. 101:      */
  102. 102:     function redirect($url$code self::S302_FOUND);
  103. 103:  
  104. 104:     /**
  105. 105:      * Sets the number of seconds before a page cached on a browser expires.
  106. 106:      * @param  int  timestamp or number of seconds
  107. 107:      * @return void 
  108. 108:      */
  109. 109:     function expire($time);
  110. 110:  
  111. 111:     /**
  112. 112:      * Checks if headers have been sent.
  113. 113:      * @return bool 
  114. 114:      */
  115. 115:     function isSent();
  116. 116:  
  117. 117:     /**
  118. 118:      * Returns a list of headers to sent.
  119. 119:      * @return array 
  120. 120:      */
  121. 121:     function getHeaders();
  122. 122:  
  123. 123:     /**
  124. 124:      * Sends a cookie.
  125. 125:      * @param  string name of the cookie
  126. 126:      * @param  string value
  127. 127:      * @param  int expiration as unix timestamp or number of seconds; Value 0 means "until the browser is closed"
  128. 128:      * @param  string 
  129. 129:      * @param  string 
  130. 130:      * @param  bool 
  131. 131:      * @return void 
  132. 132:      */
  133. 133:     function setCookie($name$value$expire$path NULL$domain NULL$secure NULL);
  134. 134:  
  135. 135:     /**
  136. 136:      * Deletes a cookie.
  137. 137:      * @param  string name of the cookie.
  138. 138:      * @param  string 
  139. 139:      * @param  string 
  140. 140:      * @param  bool 
  141. 141:      * @return void 
  142. 142:      */
  143. 143:     function deleteCookie($name$path NULL$domain NULL$secure NULL);
  144. 144: