Source for file IHttpRequest.php

Documentation is available at IHttpRequest.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:  * IHttpRequest provides access scheme for request sent via HTTP.
  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 IHttpRequest
  31. 31: {
  32. 32:     /**#@+ HTTP request method */
  33. 33:     const
  34. 34:         GET 'GET',
  35. 35:         POST 'POST',
  36. 36:         HEAD 'HEAD',
  37. 37:         PUT 'PUT',
  38. 38:         DELETE 'DELETE';
  39. 39:     /**#@-*/
  40. 40:  
  41. 41:     /**
  42. 42:      * Returns URL object.
  43. 43:      * @return UriScript 
  44. 44:      */
  45. 45:     function getUri();
  46. 46:  
  47. 47:     /********************* query, post, files & cookies ****************d*g**/
  48. 48:  
  49. 49:     /**
  50. 50:      * Returns variable provided to the script via URL query ($_GET).
  51. 51:      * If no key is passed, returns the entire array.
  52. 52:      * @param  string key
  53. 53:      * @param  mixed  default value
  54. 54:      * @return mixed 
  55. 55:      */
  56. 56:     function getQuery($key NULL$default NULL);
  57. 57:  
  58. 58:     /**
  59. 59:      * Returns variable provided to the script via POST method ($_POST).
  60. 60:      * If no key is passed, returns the entire array.
  61. 61:      * @param  string key
  62. 62:      * @param  mixed  default value
  63. 63:      * @return mixed 
  64. 64:      */
  65. 65:     function getPost($key NULL$default NULL);
  66. 66:  
  67. 67:     /**
  68. 68:      * Returns HTTP POST data in raw format (only for "application/x-www-form-urlencoded").
  69. 69:      * @return string 
  70. 70:      */
  71. 71:     function getPostRaw();
  72. 72:  
  73. 73:     /**
  74. 74:      * Returns uploaded file.
  75. 75:      * @param  string key (or more keys)
  76. 76:      * @return HttpUploadedFile 
  77. 77:      */
  78. 78:     function getFile($key);
  79. 79:  
  80. 80:     /**
  81. 81:      * Returns uploaded files.
  82. 82:      * @return array 
  83. 83:      */
  84. 84:     function getFiles();
  85. 85:  
  86. 86:     /**
  87. 87:      * Returns variable provided to the script via HTTP cookies.
  88. 88:      * @param  string key
  89. 89:      * @param  mixed  default value
  90. 90:      * @return mixed 
  91. 91:      */
  92. 92:     function getCookie($key$default NULL);
  93. 93:  
  94. 94:     /**
  95. 95:      * Returns variables provided to the script via HTTP cookies.
  96. 96:      * @return array 
  97. 97:      */
  98. 98:     function getCookies();
  99. 99:  
  100. 100:     /********************* method & headers ****************d*g**/
  101. 101:  
  102. 102:     /**
  103. 103:      * Returns HTTP request method (GET, POST, HEAD, PUT, ...). The method is case-sensitive.
  104. 104:      * @return string 
  105. 105:      */
  106. 106:     function getMethod();
  107. 107:  
  108. 108:     /**
  109. 109:      * Checks HTTP request method.
  110. 110:      * @param  string 
  111. 111:      * @return bool 
  112. 112:      */
  113. 113:     function isMethod($method);
  114. 114:  
  115. 115:     /**
  116. 116:      * Return the value of the HTTP header. Pass the header name as the
  117. 117:      * plain, HTTP-specified header name (e.g. 'Accept-Encoding').
  118. 118:      * @param  string 
  119. 119:      * @param  mixed 
  120. 120:      * @return mixed 
  121. 121:      */
  122. 122:     function getHeader($header$default NULL);
  123. 123:  
  124. 124:     /**
  125. 125:      * Returns all HTTP headers.
  126. 126:      * @return array 
  127. 127:      */
  128. 128:     function getHeaders();
  129. 129:  
  130. 130:     /**
  131. 131:      * Is the request is sent via secure channel (https).
  132. 132:      * @return bool 
  133. 133:      */
  134. 134:     function isSecured();
  135. 135:  
  136. 136:     /**
  137. 137:      * Is AJAX request?
  138. 138:      * @return bool 
  139. 139:      */
  140. 140:     function isAjax();
  141. 141:  
  142. 142:     /**
  143. 143:      * Returns the IP address of the remote client.
  144. 144:      * @return string 
  145. 145:      */
  146. 146:     function getRemoteAddress();
  147. 147:  
  148. 148:     /**
  149. 149:      * Returns the host of the remote client.
  150. 150:      * @return string 
  151. 151:      */
  152. 152:     function getRemoteHost();
  153. 153: