Skip to content

Commit 5244969

Browse files
committed
merge qiniu master
2 parents 7445a64 + 3677cf0 commit 5244969

File tree

5 files changed

+40
-6
lines changed

5 files changed

+40
-6
lines changed

src/Qiniu/Auth.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function uploadToken(
118118
'asyncOps',
119119
);
120120

121-
private static function copyPolicy($policy, $originPolicy, $strictPolicy)
121+
private static function copyPolicy(&$policy, $originPolicy, $strictPolicy)
122122
{
123123
if ($originPolicy == null) {
124124
return;

src/Qiniu/Http/Client.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,19 @@ private static function sendRequest($request)
8585
CURLOPT_CUSTOMREQUEST => $request->method,
8686
CURLOPT_URL => $request->url
8787
);
88+
8889
if (!empty($request->headers)) {
8990
$headers = array();
9091
foreach ($request->headers as $key => $val) {
9192
array_push($headers, "$key: $val");
9293
}
9394
$options[CURLOPT_HTTPHEADER] = $headers;
9495
}
96+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
9597

9698
if (!empty($request->body)) {
9799
$options[CURLOPT_POSTFIELDS] = $request->body;
98100
}
99-
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
100101
curl_setopt_array($ch, $options);
101102
$result = curl_exec($ch);
102103
$t2 = microtime(true);

src/Qiniu/Http/Response.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public function __construct($code, $duration, array $headers = array(), $body =
115115
} elseif ($code >=400) {
116116
$this->error = $body;
117117
}
118+
return;
118119
}
119120

120121
public function json()

src/Qiniu/Processing/Operation.php

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,28 @@ public function buildUrl($key, $cmd, $mod = null, array $args = array())
4949
return $url;
5050
}
5151

52+
private static $fops = array(
53+
'imageView2',
54+
'imageMogr2',
55+
'imageInfo',
56+
'exif',
57+
'watermark',
58+
'imageAve',
59+
60+
'avinfo',
61+
'pm3u8',
62+
63+
'qrcode',
64+
'md2html',
65+
);
66+
5267
public function __call($method, $args)
5368
{
69+
70+
if (!in_array($method, self::$fops)) {
71+
throw new \InvalidArgumentException("fop {$method} isn't supported");
72+
}
5473
$key = $args[0];
55-
$cmd = $method;
5674
$mode = null;
5775
if (count($args)>1) {
5876
$mode = $args[1];
@@ -62,7 +80,7 @@ public function __call($method, $args)
6280
$options = $args[2];
6381
}
6482
$options = array();
65-
$url = $this->buildUrl($key, $cmd, $mode, $options);
83+
$url = $this->buildUrl($key, $method, $mode, $options);
6684
$r = Client::get($url);
6785
if (!$r->ok()) {
6886
return array(null, new Error($url, $r));

src/Qiniu/Processing/PersistentFop.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,24 @@ public static function status($id)
8888
return array($response->json(), null);
8989
}
9090

91+
private static $pfops = array(
92+
'avthumb',
93+
'vframe',
94+
'segtime',
95+
'vsample',
96+
'vwatermark',
97+
'avconcat',
98+
99+
'concat',
100+
);
101+
91102
public function __call($method, $args)
92103
{
104+
105+
if (!in_array($method, self::$pfops)) {
106+
throw new \InvalidArgumentException("pfop {$method} isn't supported");
107+
}
93108
$key = $args[0];
94-
$cmd = $method;
95109
$mod = null;
96110
if (count($args)>1) {
97111
$mod = $args[1];
@@ -112,7 +126,7 @@ public function __call($method, $args)
112126
$target_key = $args[4];
113127
}
114128

115-
$pfop = Operation::buildOp($cmd, $mod, $options);
129+
$pfop = Operation::buildOp($method, $mod, $options);
116130
if ($target_bucket != null) {
117131
$pfop = Operation::saveas($pfop, $target_bucket, $target_key);
118132
}

0 commit comments

Comments
 (0)