Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93168148
AphrontHTTPProxyResponse.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Nov 26, 17:48
Size
1 KB
Mime Type
text/x-php
Expires
Thu, Nov 28, 17:48 (2 d)
Engine
blob
Format
Raw Data
Handle
22582038
Attached To
rPH Phabricator
AphrontHTTPProxyResponse.php
View Options
<?php
/**
* Responds to a request by proxying an HTTP future.
*
* NOTE: This is currently very inefficient for large responses, and buffers
* the entire response into memory before returning it. It should be updated
* to stream the response instead, but we need to complete additional
* infrastructure work first.
*/
final
class
AphrontHTTPProxyResponse
extends
AphrontResponse
{
private
$future
;
private
$headers
;
private
$httpCode
;
public
function
setHTTPFuture
(
HTTPSFuture
$future
)
{
$this
->
future
=
$future
;
return
$this
;
}
public
function
getHTTPFuture
()
{
return
$this
->
future
;
}
public
function
getCacheHeaders
()
{
return
array
();
}
public
function
getHeaders
()
{
$this
->
readRequestHeaders
();
return
array_merge
(
parent
::
getHeaders
(),
$this
->
headers
,
array
(
array
(
'X-Phabricator-Proxy'
,
'true'
),
));
}
public
function
buildResponseString
()
{
// TODO: AphrontResponse needs to support streaming responses.
return
$this
->
readRequest
();
}
public
function
getHTTPResponseCode
()
{
$this
->
readRequestHeaders
();
return
$this
->
httpCode
;
}
private
function
readRequestHeaders
()
{
// TODO: This should read only the headers.
$this
->
readRequest
();
}
private
function
readRequest
()
{
// TODO: This is grossly inefficient for large requests.
list
(
$status
,
$body
,
$headers
)
=
$this
->
future
->
resolve
();
$this
->
httpCode
=
$status
->
getStatusCode
();
$this
->
headers
=
$headers
;
return
$body
;
}
}
Event Timeline
Log In to Comment