1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @file AttachmentInfo.php |
5
|
|
|
* @brief This file contains the AttachmentInfo class. |
6
|
|
|
* @details |
7
|
|
|
* @author Filippo F. Fadda |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace EoC\Info; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
use Surfer\Message\Response; |
15
|
|
|
|
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @brief This is an information only purpose class. It's used by Couch::getAttachmentInfo() method. |
19
|
|
|
* @nosubgrouping |
20
|
|
|
*/ |
21
|
|
|
class AttachmentInfo { |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @var Response $response |
25
|
|
|
*/ |
26
|
|
|
private $response; |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @brief Creates the object. |
31
|
|
|
* @param[in] Response $response A response object. |
32
|
|
|
*/ |
33
|
|
|
public function __construct(Response $response) { |
34
|
|
|
$this->response = $response; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @brief Tells if the attachment is range request aware. |
40
|
|
|
* @details Used for attachments with `application/octet-stream` content type. |
41
|
|
|
*/ |
42
|
|
|
public function doesAcceptRanges() { |
43
|
|
|
return $this->response->hasHeaderField(Response::ACCEPT_RANGES_HF); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @brief Codec used to compress the attachment. |
49
|
|
|
* @details Only available if attachment’s `content_type` is in list of compressible types. |
50
|
|
|
* @return string|bool The codec name or `false` if the attachment is not compressed. |
51
|
|
|
*/ |
52
|
|
|
public function getContentEncoding() { |
53
|
|
|
if ($this->response->hasHeaderField(Response::CONTENT_ENCODING_HF)) |
54
|
|
|
return $this->response->getHeaderFieldValue(Response::CONTENT_ENCODING_HF); |
55
|
|
|
else |
56
|
|
|
return FALSE; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @brief Attachment size. |
62
|
|
|
* @details If a codec was used to compress the file, the method returns the compressed size. |
63
|
|
|
* @return integer |
64
|
|
|
*/ |
65
|
|
|
public function getSize() { |
66
|
|
|
return $this->response->getHeaderFieldValue(Response::CONTENT_LENGTH_HF); |
|
|
|
|
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @brief Base64 encoded MD5 binary digest. |
72
|
|
|
* @return integer |
73
|
|
|
*/ |
74
|
|
|
public function getMD5() { |
75
|
|
|
return $this->response->getHeaderFieldValue(Response::CONTENT_MD5_HF); |
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @brief Double quoted base64 encoded MD5 binary digest |
81
|
|
|
* @return integer |
82
|
|
|
*/ |
83
|
|
|
public function getDoubleQuotedMD5() { |
84
|
|
|
return $this->response->getHeaderFieldValue(Response::ETAG_HF); |
|
|
|
|
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
} |