|
@@ -17,7 +17,7 @@ discard block |
|
|
block discarded – undo |
|
17
|
17
|
class Request extends Http { |
|
18
|
18
|
protected static $curlAlias = array( |
|
19
|
19
|
'url' => 'CURLOPT_URL', |
|
20
|
|
- 'debug' => 'CURLOPT_VERBOSE',//for debug verbose |
|
|
20
|
+ 'debug' => 'CURLOPT_VERBOSE', //for debug verbose |
|
21
|
21
|
'method' => 'CURLOPT_CUSTOMREQUEST', |
|
22
|
22
|
'data' => 'CURLOPT_POSTFIELDS', // array or string , file begin with '@' |
|
23
|
23
|
'ua' => 'CURLOPT_USERAGENT', |
|
@@ -85,11 +85,11 @@ discard block |
|
|
block discarded – undo |
|
85
|
85
|
if (null === ($rawField = constant($alias))) {throw new InvalidArgumentException('field is invalid'); |
|
86
|
86
|
} |
|
87
|
87
|
|
|
88
|
|
- return isset($this->options[$rawField])?$this->options[$rawField]:false; |
|
|
88
|
+ return isset($this->options[$rawField]) ? $this->options[$rawField] : false; |
|
89
|
89
|
} |
|
90
|
90
|
|
|
91
|
91
|
public function hasInitialized() { |
|
92
|
|
- return $this->curlHandle?true:false; |
|
|
92
|
+ return $this->curlHandle ? true : false; |
|
93
|
93
|
} |
|
94
|
94
|
|
|
95
|
95
|
public function addQuery($data) { |
|
@@ -122,10 +122,10 @@ discard block |
|
|
block discarded – undo |
|
122
|
122
|
} |
|
123
|
123
|
|
|
124
|
124
|
if (isset($this->options['data'])) { |
|
125
|
|
- $this->options['data'] = is_array($this->options['data'])?http_build_query($this->options['data']):$this->options['data'];//for better compatibility |
|
|
125
|
+ $this->options['data'] = is_array($this->options['data']) ? http_build_query($this->options['data']) : $this->options['data']; //for better compatibility |
|
126
|
126
|
} |
|
127
|
127
|
if (isset($this->withURIQuery)) { |
|
128
|
|
- $this->options['url'] .= strpos($this->options['url'], '?') === FALSE?'?':'&'; |
|
|
128
|
+ $this->options['url'] .= strpos($this->options['url'], '?') === FALSE ? '?' : '&'; |
|
129
|
129
|
$this->options['url'] .= $this->withURIQuery; |
|
130
|
130
|
} |
|
131
|
131
|
if (isset($this->options['callback'])) { |
|
@@ -254,7 +254,7 @@ discard block |
|
|
block discarded – undo |
|
254
|
254
|
return $alias; |
|
255
|
255
|
} |
|
256
|
256
|
public function makeResponse($isMultiCurl = false) { |
|
257
|
|
- $body = $isMultiCurl?curl_multi_getcontent($this->curlHandle):curl_exec($this->curlHandle); |
|
|
257
|
+ $body = $isMultiCurl ? curl_multi_getcontent($this->curlHandle) : curl_exec($this->curlHandle); |
|
258
|
258
|
$info = curl_getinfo($this->curlHandle); |
|
259
|
259
|
$errno = curl_errno($this->curlHandle); |
|
260
|
260
|
$error = curl_error($this->curlHandle); |