| @@ 134-145 (lines=12) @@ | ||
| 131 | * |
|
| 132 | * @return ResponseInterface |
|
| 133 | */ |
|
| 134 | protected function httpPostRaw($path, $body, array $requestHeaders = []) |
|
| 135 | { |
|
| 136 | try { |
|
| 137 | $response = $this->httpClient->sendRequest( |
|
| 138 | $this->requestBuilder->create('POST', $path, $requestHeaders, $body) |
|
| 139 | ); |
|
| 140 | } catch (HttplugException\NetworkException $e) { |
|
| 141 | throw HttpServerException::networkError($e); |
|
| 142 | } |
|
| 143 | ||
| 144 | return $response; |
|
| 145 | } |
|
| 146 | ||
| 147 | /** |
|
| 148 | * Send a PUT request with JSON-encoded parameters. |
|
| @@ 156-167 (lines=12) @@ | ||
| 153 | * |
|
| 154 | * @return ResponseInterface |
|
| 155 | */ |
|
| 156 | protected function httpPut($path, array $parameters = [], array $requestHeaders = []) |
|
| 157 | { |
|
| 158 | try { |
|
| 159 | $response = $this->httpClient->sendRequest( |
|
| 160 | $this->requestBuilder->create('PUT', $path, $requestHeaders, $this->createJsonBody($parameters)) |
|
| 161 | ); |
|
| 162 | } catch (HttplugException\NetworkException $e) { |
|
| 163 | throw HttpServerException::networkError($e); |
|
| 164 | } |
|
| 165 | ||
| 166 | return $response; |
|
| 167 | } |
|
| 168 | ||
| 169 | /** |
|
| 170 | * Send a DELETE request with JSON-encoded parameters. |
|
| @@ 178-189 (lines=12) @@ | ||
| 175 | * |
|
| 176 | * @return ResponseInterface |
|
| 177 | */ |
|
| 178 | protected function httpDelete($path, array $parameters = [], array $requestHeaders = []) |
|
| 179 | { |
|
| 180 | try { |
|
| 181 | $response = $this->httpClient->sendRequest( |
|
| 182 | $this->requestBuilder->create('DELETE', $path, $requestHeaders, $this->createJsonBody($parameters)) |
|
| 183 | ); |
|
| 184 | } catch (HttplugException\NetworkException $e) { |
|
| 185 | throw HttpServerException::networkError($e); |
|
| 186 | } |
|
| 187 | ||
| 188 | return $response; |
|
| 189 | } |
|
| 190 | ||
| 191 | /** |
|
| 192 | * Create a JSON encoded version of an array of parameters. |
|