Skip to content

Commit 37ed3a5

Browse files
committed
feat: reorder default uc hosts and fix middleware test cases
1 parent 5452388 commit 37ed3a5

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/Qiniu/Config.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ final class Config
1010

1111
const RSF_HOST = 'rsf.qiniuapi.com';
1212
const API_HOST = 'api.qiniuapi.com';
13-
const RS_HOST = 'rs.qiniuapi.com'; //RS Host
14-
const UC_HOST = 'uc.qbox.me'; //UC Host
15-
const QUERY_REGION_HOST = 'kodo-config.qiniuapi.com';
13+
const RS_HOST = 'rs.qiniuapi.com'; // RS Host
14+
const UC_HOST = 'uc.qiniuapi.com'; // UC Host
15+
const QUERY_REGION_HOST = Config::UC_HOST;
1616
const RTCAPI_HOST = 'http://rtc.qiniuapi.com';
1717
const ARGUS_HOST = 'ai.qiniuapi.com';
1818
const CASTER_HOST = 'pili-caster.qiniuapi.com';
@@ -50,8 +50,8 @@ public function __construct(Region $z = null)
5050
$this->ucHost = Config::UC_HOST;
5151
$this->queryRegionHost = Config::QUERY_REGION_HOST;
5252
$this->backupQueryRegionHosts = array(
53+
"kodo-config.qiniuapi.com",
5354
"uc.qbox.me",
54-
"api.qiniu.com"
5555
);
5656
$this->backupUcHostsRetryTimes = 2;
5757
}

tests/Qiniu/Tests/ConfigTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ public function testGetApiHostV2Errored()
6666
public function testSetUcHost()
6767
{
6868
$conf = new Config();
69-
$this->assertEquals("http://uc.qbox.me", $conf->getUcHost());
69+
$this->assertEquals('http://' . Config::UC_HOST, $conf->getUcHost());
7070
$conf->setUcHost("uc.example.com");
7171
$this->assertEquals("http://uc.example.com", $conf->getUcHost());
7272

7373
$conf = new Config();
7474
$conf->useHTTPS = true;
75-
$this->assertEquals("https://uc.qbox.me", $conf->getUcHost());
75+
$this->assertEquals('https://' . Config::UC_HOST, $conf->getUcHost());
7676
$conf->setUcHost("uc.example.com");
7777
$this->assertEquals("https://uc.example.com", $conf->getUcHost());
7878
}
@@ -94,7 +94,7 @@ public function testGetRegionWithBackupDomains()
9494
"fake-uc.phpsdk.qiniu.com",
9595
array(
9696
"unavailable-uc.phpsdk.qiniu.com",
97-
"uc.qbox.me" // real uc
97+
Config::UC_HOST // real uc
9898
)
9999
);
100100
list(, $err) = $conf->getRsHostV2($this->accessKey, $this->bucketName);
@@ -108,7 +108,7 @@ public function testGetRegionWithUcAndBackupDomains()
108108
$conf->setBackupQueryRegionHosts(
109109
array(
110110
"unavailable-uc.phpsdk.qiniu.com",
111-
"uc.qbox.me" // real uc
111+
Config::UC_HOST // real uc
112112
)
113113
);
114114
list(, $err) = $conf->getRsHostV2($this->accessKey, $this->bucketName);

tests/Qiniu/Tests/MiddlewareTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function testSendWithMiddleware()
5252

5353
$request = new Request(
5454
"GET",
55-
"https://qiniu.com/index.html",
55+
"http://localhost:9000/ok.php",
5656
array(),
5757
null,
5858
$reqOpt
@@ -79,7 +79,7 @@ public function testSendWithRetryDomains()
7979
new Middleware\RetryDomainsMiddleware(
8080
array(
8181
"unavailable.phpsdk.qiniu.com",
82-
"qiniu.com",
82+
"localhost:9000",
8383
),
8484
3
8585
),
@@ -88,7 +88,7 @@ public function testSendWithRetryDomains()
8888

8989
$request = new Request(
9090
"GET",
91-
"https://fake.phpsdk.qiniu.com/index.html",
91+
"http://fake.phpsdk.qiniu.com/ok.php",
9292
array(),
9393
null,
9494
$reqOpt
@@ -130,7 +130,7 @@ public function testSendFailFastWithRetryDomains()
130130
new Middleware\RetryDomainsMiddleware(
131131
array(
132132
"unavailable.phpsdk.qiniu.com",
133-
"qiniu.com",
133+
"localhost:9000",
134134
),
135135
3,
136136
function () {
@@ -142,7 +142,7 @@ function () {
142142

143143
$request = new Request(
144144
"GET",
145-
"https://fake.phpsdk.qiniu.com/index.html",
145+
"http://fake.phpsdk.qiniu.com/ok.php",
146146
array(),
147147
null,
148148
$reqOpt

0 commit comments

Comments
 (0)