@@ -57,6 +57,27 @@ public function getUpHost($accessKey, $bucket)
5757 return $ scheme . $ host ;
5858 }
5959
60+ public function getUpHostV2 ($ accessKey , $ bucket )
61+ {
62+ list ($ region , $ err ) = $ this ->getRegionV2 ($ accessKey , $ bucket );
63+ if ($ err != null ) {
64+ return array (null , $ err );
65+ }
66+
67+ if ($ this ->useHTTPS === true ) {
68+ $ scheme = "https:// " ;
69+ } else {
70+ $ scheme = "http:// " ;
71+ }
72+
73+ $ host = $ region ->srcUpHosts [0 ];
74+ if ($ this ->useCdnDomains === true ) {
75+ $ host = $ region ->cdnUpHosts [0 ];
76+ }
77+
78+ return array ($ scheme . $ host , null );
79+ }
80+
6081 public function getUpBackupHost ($ accessKey , $ bucket )
6182 {
6283 $ region = $ this ->getRegion ($ accessKey , $ bucket );
@@ -74,6 +95,27 @@ public function getUpBackupHost($accessKey, $bucket)
7495 return $ scheme . $ host ;
7596 }
7697
98+ public function getUpBackupHostV2 ($ accessKey , $ bucket )
99+ {
100+ list ($ region , $ err ) = $ this ->getRegionV2 ($ accessKey , $ bucket );
101+ if ($ err != null ) {
102+ return array (null , $ err );
103+ }
104+
105+ if ($ this ->useHTTPS === true ) {
106+ $ scheme = "https:// " ;
107+ } else {
108+ $ scheme = "http:// " ;
109+ }
110+
111+ $ host = $ region ->cdnUpHosts [0 ];
112+ if ($ this ->useCdnDomains === true ) {
113+ $ host = $ region ->srcUpHosts [0 ];
114+ }
115+
116+ return array ($ scheme . $ host , null );
117+ }
118+
77119 public function getRsHost ($ accessKey , $ bucket )
78120 {
79121 $ region = $ this ->getRegion ($ accessKey , $ bucket );
@@ -87,6 +129,22 @@ public function getRsHost($accessKey, $bucket)
87129 return $ scheme . $ region ->rsHost ;
88130 }
89131
132+ public function getRsHostV2 ($ accessKey , $ bucket )
133+ {
134+ list ($ region , $ err ) = $ this ->getRegionV2 ($ accessKey , $ bucket );
135+ if ($ err != null ) {
136+ return array (null , $ err );
137+ }
138+
139+ if ($ this ->useHTTPS === true ) {
140+ $ scheme = "https:// " ;
141+ } else {
142+ $ scheme = "http:// " ;
143+ }
144+
145+ return array ($ scheme . $ region ->rsHost , null );
146+ }
147+
90148 public function getRsfHost ($ accessKey , $ bucket )
91149 {
92150 $ region = $ this ->getRegion ($ accessKey , $ bucket );
@@ -100,6 +158,22 @@ public function getRsfHost($accessKey, $bucket)
100158 return $ scheme . $ region ->rsfHost ;
101159 }
102160
161+ public function getRsfHostV2 ($ accessKey , $ bucket )
162+ {
163+ list ($ region , $ err ) = $ this ->getRegionV2 ($ accessKey , $ bucket );
164+ if ($ err != null ) {
165+ return array (null , $ err );
166+ }
167+
168+ if ($ this ->useHTTPS === true ) {
169+ $ scheme = "https:// " ;
170+ } else {
171+ $ scheme = "http:// " ;
172+ }
173+
174+ return array ($ scheme . $ region ->rsfHost , null );
175+ }
176+
103177 public function getIovipHost ($ accessKey , $ bucket )
104178 {
105179 $ region = $ this ->getRegion ($ accessKey , $ bucket );
@@ -113,6 +187,22 @@ public function getIovipHost($accessKey, $bucket)
113187 return $ scheme . $ region ->iovipHost ;
114188 }
115189
190+ public function getIovipHostV2 ($ accessKey , $ bucket )
191+ {
192+ list ($ region , $ err ) = $ this ->getRegionV2 ($ accessKey , $ bucket );
193+ if ($ err != null ) {
194+ return array (null , $ err );
195+ }
196+
197+ if ($ this ->useHTTPS === true ) {
198+ $ scheme = "https:// " ;
199+ } else {
200+ $ scheme = "http:// " ;
201+ }
202+
203+ return array ($ scheme . $ region ->iovipHost , null );
204+ }
205+
116206 public function getApiHost ($ accessKey , $ bucket )
117207 {
118208 $ region = $ this ->getRegion ($ accessKey , $ bucket );
@@ -126,6 +216,22 @@ public function getApiHost($accessKey, $bucket)
126216 return $ scheme . $ region ->apiHost ;
127217 }
128218
219+ public function getApiHostV2 ($ accessKey , $ bucket )
220+ {
221+ list ($ region , $ err ) = $ this ->getRegionV2 ($ accessKey , $ bucket );
222+ if ($ err != null ) {
223+ return array (null , $ err );
224+ }
225+
226+ if ($ this ->useHTTPS === true ) {
227+ $ scheme = "https:// " ;
228+ } else {
229+ $ scheme = "http:// " ;
230+ }
231+
232+ return array ($ scheme . $ region ->apiHost , null );
233+ }
234+
129235 private function getRegion ($ accessKey , $ bucket )
130236 {
131237 $ cacheId = "$ accessKey: $ bucket " ;
@@ -147,4 +253,25 @@ private function getRegion($accessKey, $bucket)
147253 }
148254 return $ region ;
149255 }
256+
257+ private function getRegionV2 ($ accessKey , $ bucket )
258+ {
259+ $ cacheId = "$ accessKey: $ bucket " ;
260+
261+ if (isset ($ this ->regionCache [$ cacheId ])) {
262+ $ region = $ this ->regionCache [$ cacheId ];
263+ } elseif (isset ($ this ->zone )) {
264+ $ region = $ this ->zone ;
265+ $ this ->regionCache [$ cacheId ] = $ region ;
266+ } else {
267+ $ region = Zone::queryZone ($ accessKey , $ bucket );
268+ if (is_array ($ region )) {
269+ list ($ region , $ err ) = $ region ;
270+ return array ($ region , $ err );
271+ }
272+ $ this ->regionCache [$ cacheId ] = $ region ;
273+ }
274+
275+ return array ($ region , null );
276+ }
150277}
0 commit comments