Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F3282625
ConduitFuture.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
2 KB
Referenced Files
None
Subscribers
None
ConduitFuture.php
View Options
<?php
final
class
ConduitFuture
extends
FutureProxy
{
private
$client
;
private
$engine
;
private
$conduitMethod
;
private
$profilerCallID
;
public
function
setClient
(
ConduitClient
$client
,
$method
)
{
$this
->
client
=
$client
;
$this
->
conduitMethod
=
$method
;
return
$this
;
}
public
function
isReady
(
)
{
if
(
$this
->
profilerCallID
===
null
)
{
$profiler
=
PhutilServiceProfiler
::
getInstance
(
)
;
$this
->
profilerCallID
=
$profiler
->
beginServiceCall
(
array
(
'type'
=>
'conduit'
,
'method'
=>
$this
->
conduitMethod
,
'size'
=>
$this
->
getProxiedFuture
(
)
->
getHTTPRequestByteLength
(
)
,
)
)
;
}
return
parent
::
isReady
(
)
;
}
protected
function
didReceiveResult
(
$result
)
{
if
(
$this
->
profilerCallID
!==
null
)
{
$profiler
=
PhutilServiceProfiler
::
getInstance
(
)
;
$profiler
->
endServiceCall
(
$this
->
profilerCallID
,
array
(
)
)
;
}
list
(
$status
,
$body
,
$headers
)
=
$result
;
if
(
$status
->
isError
(
)
)
{
throw
$status
;
}
$capabilities
=
array
(
)
;
foreach
(
$headers
as
$header
)
{
list
(
$name
,
$value
)
=
$header
;
if
(
!
strcasecmp
(
$name
,
'X-Conduit-Capabilities'
)
)
{
$capabilities
=
explode
(
' '
,
$value
)
;
break
;
}
}
if
(
$capabilities
)
{
$this
->
client
->
enableCapabilities
(
$capabilities
)
;
}
$raw
=
$body
;
$shield
=
'for(;;);'
;
if
(
!
strncmp
(
$raw
,
$shield
,
strlen
(
$shield
)
)
)
{
$raw
=
substr
(
$raw
,
strlen
(
$shield
)
)
;
}
$data
=
null
;
try
{
$data
=
phutil_json_decode
(
$raw
)
;
}
catch
(
PhutilJSONParserException
$ex
)
{
throw
new
PhutilProxyException
(
pht
(
'Host returned HTTP/200, but invalid JSON data in response to '
.
'a Conduit method call.'
)
,
$ex
)
;
}
if
(
$data
[
'error_code'
]
)
{
throw
new
ConduitClientException
(
$data
[
'error_code'
]
,
$data
[
'error_info'
]
)
;
}
$result
=
$data
[
'result'
]
;
$result
=
$this
->
client
->
didReceiveResponse
(
$this
->
conduitMethod
,
$result
)
;
return
$result
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Mar 24, 09:45 (4 w, 19 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1141849
Default Alt Text
ConduitFuture.php (2 KB)
Attached To
Mode
rARC Arcanist
Attached
Detach File
Event Timeline
Log In to Comment