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