mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Return Git HTTP error messages in an HTTP header
Summary: Ref T13590. Currently, when you encounter a HTTP error in Git, there is no apparent way to make the client show any additional useful information. In particular, the response body is ignored. We can partially get around this by putting the information in an "X-Phabricator-Message: ..." HTTP header, which is visible with "GIT_CURL_VERBOSE=1 git ...". Users won't normally know to look here, but it's still better than nothing. Test Plan: - Ran "GIT_CURL_VERBOSE=1 git fetch" against a Phabricator HTTP URI that returned a HTTP/500 error. - Before: no clue what happened on the client. - After: client shows useful message in the "X-Phabricator-Message" header in debug output. Maniphest Tasks: T13590 Differential Revision: https://secure.phabricator.com/D21523
This commit is contained in:
parent
acd767c7f3
commit
3a74701555
1 changed files with 13 additions and 1 deletions
|
@ -2,7 +2,9 @@
|
|||
|
||||
/**
|
||||
* In Git, there appears to be no way to send a message which will be output
|
||||
* by `git clone http://...`, although the response code is visible.
|
||||
* by `git clone http://...`, although the response code is visible. We send
|
||||
* the message in a header which is visible with "GIT_CURL_VERBOSE" if you
|
||||
* know where to look.
|
||||
*
|
||||
* In Mercurial, the HTTP status response message is printed to the console, so
|
||||
* we send human-readable text there.
|
||||
|
@ -44,6 +46,16 @@ final class PhabricatorVCSResponse extends AphrontResponse {
|
|||
);
|
||||
}
|
||||
|
||||
$message = $this->getMessage();
|
||||
if (strlen($message)) {
|
||||
foreach (phutil_split_lines($message, false) as $line) {
|
||||
$headers[] = array(
|
||||
'X-Phabricator-Message',
|
||||
$line,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue