-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathHttpResponse.php
More file actions
43 lines (31 loc) · 873 Bytes
/
HttpResponse.php
File metadata and controls
43 lines (31 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
namespace WF\Hypernova\Http;
class Response {
private $rawBody;
private $headers;
private $response;
public function __construct($curl, $response) {
$this->rawBody = $response;
if (empty($response)) {
throw new Exception("Empty Response", 0);
return;
}
$info = curl_getinfo($curl);
if (empty($info['http_code'])) {
throw new Exception("No HTTP code was returned", 0);
return;
}
$this->response = $info;
$this->headers = $info['request_header'];
if($info['http_code'] > 399) {
throw new Exception($response, $info['http_code'] );
}
}
public function getBody() {
return $this->rawBody;
}
public function getHeaders() {
return $this->headers;
}
}
?>