1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-11 09:22:40 +01:00
phorge-phorge/src/applications/diffusion/response/DiffusionGitResponse.php
epriestley 7d9dfb561d Serve Git reads over HTTP
Summary: Mostly ripped from D7391. No writes yet.

Test Plan: Ran `git clone` against a local over HTTP, got a clone.

Reviewers: btrahan, hach-que

Reviewed By: hach-que

CC: aran

Maniphest Tasks: T2230

Differential Revision: https://secure.phabricator.com/D7423
2013-10-29 15:32:40 -07:00

44 lines
920 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 $this->headers;
}
public function getCacheHeaders() {
return array();
}
public function getHTTPResponseCode() {
return $this->httpCode;
}
}