mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-25 00:02:41 +01:00
6324669748
Summary: Ref T2230. This is easily the worst thing I've had to write in a while. I'll leave some notes inline. Test Plan: Ran `hg clone http://...` on a hosted repo. Ran `hg push` on the same. Changed sync'd both ways. Reviewers: asherkin, btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2230 Differential Revision: https://secure.phabricator.com/D7520
44 lines
955 B
PHP
44 lines
955 B
PHP
<?php
|
|
|
|
final class DiffusionGitResponse extends AphrontResponse {
|
|
|
|
private $httpCode;
|
|
private $headers = array();
|
|
private $response;
|
|
|
|
public function setGitData($data) {
|
|
list($headers, $body) = explode("\r\n\r\n", $data, 2);
|
|
$this->response = $body;
|
|
$headers = explode("\r\n", $headers);
|
|
|
|
$matches = null;
|
|
$this->httpCode = 200;
|
|
$this->headers = array();
|
|
foreach ($headers as $header) {
|
|
if (preg_match('/^Status:\s*(\d+)/i', $header, $matches)) {
|
|
$this->httpCode = (int)$matches[1];
|
|
} else {
|
|
$this->headers[] = explode(': ', $header, 2);
|
|
}
|
|
}
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function buildResponseString() {
|
|
return $this->response;
|
|
}
|
|
|
|
public function getHeaders() {
|
|
return array_merge(parent::getHeaders(), $this->headers);
|
|
}
|
|
|
|
public function getCacheHeaders() {
|
|
return array();
|
|
}
|
|
|
|
public function getHTTPResponseCode() {
|
|
return $this->httpCode;
|
|
}
|
|
|
|
}
|