/// <summary>Get the HTTP response code from the request.</summary>
/// <remarks>
/// Get the HTTP response code from the request.
/// <p>
/// Roughly the same as <code>c.getResponseCode()</code> but the
/// ConnectException is translated to be more understandable.
/// </remarks>
/// <param name="c">connection the code should be obtained from.</param>
/// <returns>
/// r HTTP status code, usually 200 to indicate success. See
/// <see cref="Sharpen.HttpURLConnection">Sharpen.HttpURLConnection</see>
/// for other defined constants.
/// </returns>
/// <exception cref="System.IO.IOException">communications error prevented obtaining the response code.
/// </exception>
public static int Response(HttpURLConnection c)
{
try
{
return c.GetResponseCode();
}
catch (ConnectException ce)
{
string host = c.GetURL().GetHost();
// The standard J2SE error message is not very useful.
//
if ("Connection timed out: connect".Equals(ce.Message))
{
throw new ConnectException(MessageFormat.Format(JGitText.Get().connectionTimeOut,
host));
}
throw new ConnectException(ce.Message + " " + host);
}
}