-
Notifications
You must be signed in to change notification settings - Fork 0
/
Response.php
executable file
·42 lines (36 loc) · 1.13 KB
/
Response.php
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
<?php
class Response {
// property declaration
public $mimeType;
public $downloadType;
public $status;
public $length = 0;
// method declaration
function Response($response) {
$lines = explode("\n",$response);
foreach($lines as $line ) {
if (preg_match("/^Content-Type:(.*);.*/",$line,$matches)) {
$mt = explode("/",$matches[1]);
$this->mimeType = trim($mt[1]);
$this->downloadType = trim($mt[0]);
} else if(preg_match("/^Content-Type:(.*)/",$line,$matches)) {
$mt = explode("/",$matches[1]);
$this->mimeType = trim($mt[1]);
$this->downloadType = trim($mt[0]);
} else if (preg_match("/^Status:(.*)/",$line,$matches)) {
$this->status = trim($matches[1]);
} else if (preg_match("/^HTTP\/\d.\d (\d+).*/",$line,$matches)) {
$this->status = trim($matches[1]);
} else if (preg_match("/^Content-Length:(.*)/",$line,$matches)) {
$this->length = trim($matches[1]);
}
}
/*
print $this->mimeType;
print $this->downloadType;
print $this->status;
print $this->length;
*/
}
}
?>