HttpRequest.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\utils\Ocr\Http;
  8. /*
  9. * Licensed to the Apache Software Foundation (ASF) under one
  10. * or more contributor license agreements. See the NOTICE file
  11. * distributed with this work for additional information
  12. * regarding copyright ownership. The ASF licenses this file
  13. * to you under the Apache License, Version 2.0 (the
  14. * "License"); you may not use this file except in compliance
  15. * with the License. You may obtain a copy of the License at
  16. *
  17. * http://www.apache.org/licenses/LICENSE-2.0
  18. *
  19. * Unless required by applicable law or agreed to in writing,
  20. * software distributed under the License is distributed on an
  21. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  22. * KIND, either express or implied. See the License for the
  23. * specific language governing permissions and limitations
  24. * under the License.
  25. */
  26. class HttpRequest
  27. {
  28. protected $host;
  29. protected $path;
  30. protected $method;
  31. protected $appKey;
  32. protected $appSecret;
  33. protected $headers = array();
  34. protected $signHeaders = array();
  35. protected $querys = array();
  36. protected $bodys = array();
  37. function __construct($host, $path, $method, $appKey, $appSecret)
  38. {
  39. $this->host = $host;
  40. $this->path = $path;
  41. $this->method = $method;
  42. $this->appKey = $appKey;
  43. $this->appSecret = $appSecret;
  44. }
  45. public function getHeaders()
  46. {
  47. return $this->headers;
  48. }
  49. public function setHeader($key, $value)
  50. {
  51. if (null == $this->headers) {
  52. $this->headers = array();
  53. }
  54. $this->headers[$key] = $value;
  55. }
  56. public function getHeader($key)
  57. {
  58. return $this->headers[$key];
  59. }
  60. public function removeHeader($key)
  61. {
  62. unset($this->headers[$key]);
  63. }
  64. public function getQuerys()
  65. {
  66. return $this->querys;
  67. }
  68. public function setQuery($key, $value)
  69. {
  70. if (null == $this->querys) {
  71. $this->querys = array();
  72. }
  73. $this->querys[$key] = $value;
  74. }
  75. public function getQuery($key)
  76. {
  77. return $this->querys[$key];
  78. }
  79. public function removeQuery($key)
  80. {
  81. unset($this->querys[$key]);
  82. }
  83. public function getBodys()
  84. {
  85. return $this->bodys;
  86. }
  87. public function setBody($key, $value)
  88. {
  89. if (null == $this->bodys) {
  90. $this->bodys = array();
  91. }
  92. $this->bodys[$key] = $value;
  93. }
  94. public function getBody($key)
  95. {
  96. return $this->bodys[$key];
  97. }
  98. public function removeBody($key)
  99. {
  100. unset($this->bodys[$key]);
  101. }
  102. public function setBodyStream($value)
  103. {
  104. if (null == $this->bodys) {
  105. $this->bodys = array();
  106. }
  107. $this->bodys[""] = $value;
  108. }
  109. public function setBodyString($value)
  110. {
  111. if (null == $this->bodys) {
  112. $this->bodys = array();
  113. }
  114. $this->bodys[""] = $value;
  115. }
  116. public function getSignHeaders()
  117. {
  118. return $this->signHeaders;
  119. }
  120. public function setSignHeader($value)
  121. {
  122. if (null == $this->signHeaders) {
  123. $this->signHeaders = array();
  124. }
  125. if (!in_array($value, $this->signHeaders)) {
  126. array_push($this->signHeaders, $value);
  127. }
  128. }
  129. public function removeSignHeader($value)
  130. {
  131. unset($this->signHeaders[$value]);
  132. }
  133. public function getHost()
  134. {
  135. return $this->host;
  136. }
  137. public function setHost($host)
  138. {
  139. $this->host = $host;
  140. }
  141. public function getPath()
  142. {
  143. return $this->path;
  144. }
  145. public function setPath($path)
  146. {
  147. $this->path = $path;
  148. }
  149. public function getMethod()
  150. {
  151. return $this->method;
  152. }
  153. public function setMethod($method)
  154. {
  155. $this->method = $method;
  156. }
  157. public function getAppKey()
  158. {
  159. return $this->appKey;
  160. }
  161. public function setAppKey($appKey)
  162. {
  163. $this->appKey = $appKey;
  164. }
  165. public function getAppSecret()
  166. {
  167. return $this->appSecret;
  168. }
  169. public function setAppSecret($appSecret)
  170. {
  171. $this->appSecret = $appSecret;
  172. }
  173. }