1 | <?php |
||
29 | class Request implements RequestInterface |
||
30 | { |
||
31 | /** |
||
32 | * A container of headers. |
||
33 | * |
||
34 | * @var \Jyggen\Curl\HeaderBag |
||
35 | */ |
||
36 | public $headers; |
||
37 | |||
38 | /** |
||
39 | * The raw response body. |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $content; |
||
44 | |||
45 | /** |
||
46 | * Protected default values that can't be changed. |
||
47 | * These are required for this library to work correctly. |
||
48 | * |
||
49 | * @var array |
||
50 | */ |
||
51 | protected $defaults = [ |
||
52 | CURLOPT_RETURNTRANSFER => true, |
||
53 | CURLOPT_HEADER => true, |
||
54 | ]; |
||
55 | |||
56 | /** |
||
57 | * If this request has been executed. |
||
58 | * |
||
59 | * @var boolean |
||
60 | */ |
||
61 | protected $executed = false; |
||
62 | |||
63 | /** |
||
64 | * The cURL resource attached. |
||
65 | * |
||
66 | * @var resource |
||
67 | */ |
||
68 | protected $handle; |
||
69 | |||
70 | /** |
||
71 | * Response object. |
||
72 | * |
||
73 | * @var \Jyggen\Curl\Response |
||
74 | */ |
||
75 | protected $response; |
||
76 | |||
77 | /** |
||
78 | * Create a new Request instance. |
||
79 | * |
||
80 | * @param string $url |
||
81 | */ |
||
82 | public function __construct($url) |
||
91 | |||
92 | /** |
||
93 | * Shutdown sequence. |
||
94 | * @return void |
||
95 | */ |
||
96 | public function __destruct() |
||
100 | |||
101 | /** |
||
102 | * Retrieve the latest error. |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | public function getErrorMessage() |
||
111 | |||
112 | /** |
||
113 | * Retrieve the cURL handle. |
||
114 | * |
||
115 | * @return resource |
||
116 | */ |
||
117 | public function getHandle() |
||
121 | |||
122 | /** |
||
123 | * Get information regarding the request. |
||
124 | * |
||
125 | * @param int $key null |
||
126 | * @return mixed |
||
127 | */ |
||
128 | public function getInfo($key = null) |
||
136 | |||
137 | /** |
||
138 | * Get the raw response. |
||
139 | * |
||
140 | * @return string |
||
141 | */ |
||
142 | public function getRawResponse() |
||
146 | |||
147 | /** |
||
148 | * Get the response. |
||
149 | * |
||
150 | * @return Response |
||
151 | */ |
||
152 | public function getResponse() |
||
160 | |||
161 | /** |
||
162 | * Set an option for the request. |
||
163 | * |
||
164 | * @param mixed $option |
||
165 | * @param mixed $value null |
||
166 | * @return RequestInterface |
||
167 | */ |
||
168 | public function setOption($option, $value = null) |
||
185 | |||
186 | /** |
||
187 | * Execute the request. |
||
188 | * |
||
189 | * @return void |
||
190 | */ |
||
191 | public function execute() |
||
202 | |||
203 | /** |
||
204 | * If the request has been executed. |
||
205 | * |
||
206 | * @return boolean |
||
207 | */ |
||
208 | public function isExecuted() |
||
212 | |||
213 | /** |
||
214 | * If the request was successful. |
||
215 | * |
||
216 | * @return boolean |
||
217 | */ |
||
218 | public function isSuccessful() |
||
222 | |||
223 | public function setRawResponse($content) |
||
228 | } |
||
229 |