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