*/
public class TransportHttp extends HttpTransport implements WalkTransport,
PackTransport {
- private static final String SVC_UPLOAD_PACK = "git-upload-pack";
+ private static final String SVC_UPLOAD_PACK = "git-upload-pack"; //$NON-NLS-1$
- private static final String SVC_RECEIVE_PACK = "git-receive-pack";
+ private static final String SVC_RECEIVE_PACK = "git-receive-pack"; //$NON-NLS-1$
private static final String userAgent = computeUserAgent();
if (!uri.isRemote())
return false;
final String s = uri.getScheme();
- return "http".equals(s) || "https".equals(s) || "ftp".equals(s);
+ return "http".equals(s) || "https".equals(s) || "ftp".equals(s); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
private static String computeUserAgent() {
final int postBuffer;
HttpConfig(final Config rc) {
- postBuffer = rc.getInt("http", "postbuffer", 1 * 1024 * 1024);
+ postBuffer = rc.getInt("http", "postbuffer", 1 * 1024 * 1024); //$NON-NLS-1$ //$NON-NLS-2$
}
}
super(local, uri);
try {
String uriString = uri.toString();
- if (!uriString.endsWith("/"))
- uriString += "/";
+ if (!uriString.endsWith("/")) //$NON-NLS-1$
+ uriString += "/"; //$NON-NLS-1$
baseUrl = new URL(uriString);
- objectsUrl = new URL(baseUrl, "objects/");
+ objectsUrl = new URL(baseUrl, "objects/"); //$NON-NLS-1$
} catch (MalformedURLException e) {
throw new NotSupportedException(MessageFormat.format(JGitText.get().invalidURL, uri), e);
}
b.append(Constants.INFO_REFS);
if (useSmartHttp) {
- b.append(b.indexOf("?") < 0 ? '?' : '&');
- b.append("service=");
+ b.append(b.indexOf("?") < 0 ? '?' : '&'); //$NON-NLS-1$
+ b.append("service="); //$NON-NLS-1$
b.append(service);
}
for (;;) {
final HttpURLConnection conn = httpOpen(u);
if (useSmartHttp) {
- String exp = "application/x-" + service + "-advertisement";
- conn.setRequestProperty(HDR_ACCEPT, exp + ", */*");
+ String exp = "application/x-" + service + "-advertisement"; //$NON-NLS-1$ //$NON-NLS-2$
+ conn.setRequestProperty(HDR_ACCEPT, exp + ", */*"); //$NON-NLS-1$
} else {
- conn.setRequestProperty(HDR_ACCEPT, "*/*");
+ conn.setRequestProperty(HDR_ACCEPT, "*/*"); //$NON-NLS-1$
}
final int status = HttpSupport.response(conn);
switch (status) {
return conn;
case HttpURLConnection.HTTP_NOT_FOUND:
- throw new NoRemoteRepositoryException(uri, u + " not found");
+ throw new NoRemoteRepositoryException(uri,
+ MessageFormat.format(JGitText.get().uriNotFound, u));
case HttpURLConnection.HTTP_UNAUTHORIZED:
authMethod = HttpAuthMethod.scanResponse(conn);
if (authMethod == HttpAuthMethod.NONE)
- throw new TransportException(uri,
- "authentication not supported");
+ throw new TransportException(uri, MessageFormat.format(
+ JGitText.get().authenticationNotSupported, uri));
if (1 < authAttempts || uri.getUser() == null)
- throw new TransportException(uri, "not authorized");
+ throw new TransportException(uri,
+ JGitText.get().notAuthorized);
authMethod.authorize(uri);
authAttempts++;
continue;
case HttpURLConnection.HTTP_FORBIDDEN:
- throw new TransportException(uri, service
- + " not permitted");
+ throw new TransportException(uri, MessageFormat.format(
+ JGitText.get().serviceNotPermitted, service));
default:
- String err = status + " " + conn.getResponseMessage();
+ String err = status + " " + conn.getResponseMessage(); //$NON-NLS-1$
throw new TransportException(uri, err);
}
}
conn.setRequestMethod(method);
conn.setUseCaches(false);
conn.setRequestProperty(HDR_ACCEPT_ENCODING, ENCODING_GZIP);
- conn.setRequestProperty(HDR_PRAGMA, "no-cache");//$NON-NLS-1$
+ conn.setRequestProperty(HDR_PRAGMA, "no-cache"); //$NON-NLS-1$
conn.setRequestProperty(HDR_USER_AGENT, userAgent);
conn.setConnectTimeout(getTimeout() * 1000);
conn.setReadTimeout(getTimeout() * 1000);
}
private boolean isSmartHttp(final HttpURLConnection c, final String service) {
- final String expType = "application/x-" + service + "-advertisement";
+ final String expType = "application/x-" + service + "-advertisement"; //$NON-NLS-1$ //$NON-NLS-2$
final String actType = c.getContentType();
return expType.equals(actType);
}
final PacketLineIn pckIn = new PacketLineIn(new UnionInputStream(
new ByteArrayInputStream(magic), in));
- final String exp = "# service=" + service;
+ final String exp = "# service=" + service; //$NON-NLS-1$
final String act = pckIn.readString();
if (!exp.equals(act)) {
throw new TransportException(uri, MessageFormat.format(
final String s = br.readLine();
if (s == null || s.length() == 0)
break;
- if (!s.startsWith("P pack-") || !s.endsWith(".pack"))
+ if (!s.startsWith("P pack-") || !s.endsWith(".pack")) //$NON-NLS-1$ //$NON-NLS-2$
throw invalidAdvertisement(s);
packs.add(s.substring(2));
}
case HttpURLConnection.HTTP_NOT_FOUND:
throw new FileNotFoundException(u.toString());
default:
- throw new IOException(u.toString() + ": "
- + HttpSupport.response(c) + " "
+ throw new IOException(u.toString() + ": " //$NON-NLS-1$
+ + HttpSupport.response(c) + " " //$NON-NLS-1$
+ c.getResponseMessage());
}
}
name = line.substring(tab + 1);
id = ObjectId.fromString(line.substring(0, tab));
- if (name.endsWith("^{}")) {
+ if (name.endsWith("^{}")) { //$NON-NLS-1$
name = name.substring(0, name.length() - 3);
final Ref prior = avail.get(name);
if (prior == null)
throw outOfOrderAdvertisement(name);
if (prior.getPeeledObjectId() != null)
- throw duplicateAdvertisement(name + "^{}");
+ throw duplicateAdvertisement(name + "^{}"); //$NON-NLS-1$
avail.put(name, new ObjectIdRef.PeeledTag(
Ref.Storage.NETWORK, name,
Service(final String serviceName) {
this.serviceName = serviceName;
- this.requestType = "application/x-" + serviceName + "-request";
- this.responseType = "application/x-" + serviceName + "-result";
+ this.requestType = "application/x-" + serviceName + "-request"; //$NON-NLS-1$ //$NON-NLS-2$
+ this.responseType = "application/x-" + serviceName + "-result"; //$NON-NLS-1$ //$NON-NLS-2$
this.execute = new HttpExecuteStream();
this.in = new UnionInputStream(execute);
final int status = HttpSupport.response(conn);
if (status != HttpURLConnection.HTTP_OK) {
- throw new TransportException(uri, status + " "
+ throw new TransportException(uri, status + " " //$NON-NLS-1$
+ conn.getResponseMessage());
}