|
|
@ -371,12 +371,9 @@ public class TransportHttp extends HttpTransport implements WalkTransport, |
|
|
|
private WalkFetchConnection newDumbConnection(InputStream in) |
|
|
|
private WalkFetchConnection newDumbConnection(InputStream in) |
|
|
|
throws IOException, PackProtocolException { |
|
|
|
throws IOException, PackProtocolException { |
|
|
|
HttpObjectDB d = new HttpObjectDB(objectsUrl); |
|
|
|
HttpObjectDB d = new HttpObjectDB(objectsUrl); |
|
|
|
BufferedReader br = toBufferedReader(in); |
|
|
|
|
|
|
|
Map<String, Ref> refs; |
|
|
|
Map<String, Ref> refs; |
|
|
|
try { |
|
|
|
try (BufferedReader br = toBufferedReader(in)) { |
|
|
|
refs = d.readAdvertisedImpl(br); |
|
|
|
refs = d.readAdvertisedImpl(br); |
|
|
|
} finally { |
|
|
|
|
|
|
|
br.close(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!refs.containsKey(HEAD)) { |
|
|
|
if (!refs.containsKey(HEAD)) { |
|
|
@ -391,8 +388,8 @@ public class TransportHttp extends HttpTransport implements WalkTransport, |
|
|
|
int status = HttpSupport.response(conn); |
|
|
|
int status = HttpSupport.response(conn); |
|
|
|
switch (status) { |
|
|
|
switch (status) { |
|
|
|
case HttpConnection.HTTP_OK: { |
|
|
|
case HttpConnection.HTTP_OK: { |
|
|
|
br = toBufferedReader(openInputStream(conn)); |
|
|
|
try (BufferedReader br = toBufferedReader( |
|
|
|
try { |
|
|
|
openInputStream(conn))) { |
|
|
|
String line = br.readLine(); |
|
|
|
String line = br.readLine(); |
|
|
|
if (line != null && line.startsWith(RefDirectory.SYMREF)) { |
|
|
|
if (line != null && line.startsWith(RefDirectory.SYMREF)) { |
|
|
|
String target = line.substring(RefDirectory.SYMREF.length()); |
|
|
|
String target = line.substring(RefDirectory.SYMREF.length()); |
|
|
@ -406,8 +403,6 @@ public class TransportHttp extends HttpTransport implements WalkTransport, |
|
|
|
HEAD, ObjectId.fromString(line)); |
|
|
|
HEAD, ObjectId.fromString(line)); |
|
|
|
refs.put(r.getName(), r); |
|
|
|
refs.put(r.getName(), r); |
|
|
|
} |
|
|
|
} |
|
|
|
} finally { |
|
|
|
|
|
|
|
br.close(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
@ -438,8 +433,7 @@ public class TransportHttp extends HttpTransport implements WalkTransport, |
|
|
|
final String service = SVC_RECEIVE_PACK; |
|
|
|
final String service = SVC_RECEIVE_PACK; |
|
|
|
try { |
|
|
|
try { |
|
|
|
final HttpConnection c = connect(service); |
|
|
|
final HttpConnection c = connect(service); |
|
|
|
final InputStream in = openInputStream(c); |
|
|
|
try (InputStream in = openInputStream(c)) { |
|
|
|
try { |
|
|
|
|
|
|
|
if (isSmartHttp(c, service)) { |
|
|
|
if (isSmartHttp(c, service)) { |
|
|
|
return smartPush(service, c, in); |
|
|
|
return smartPush(service, c, in); |
|
|
|
} else if (!useSmartHttp) { |
|
|
|
} else if (!useSmartHttp) { |
|
|
@ -450,8 +444,6 @@ public class TransportHttp extends HttpTransport implements WalkTransport, |
|
|
|
final String msg = JGitText.get().remoteDoesNotSupportSmartHTTPPush; |
|
|
|
final String msg = JGitText.get().remoteDoesNotSupportSmartHTTPPush; |
|
|
|
throw new NotSupportedException(msg); |
|
|
|
throw new NotSupportedException(msg); |
|
|
|
} |
|
|
|
} |
|
|
|
} finally { |
|
|
|
|
|
|
|
in.close(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} catch (NotSupportedException err) { |
|
|
|
} catch (NotSupportedException err) { |
|
|
|
throw err; |
|
|
|
throw err; |
|
|
@ -966,9 +958,7 @@ public class TransportHttp extends HttpTransport implements WalkTransport, |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
Collection<String> getPackNames() throws IOException { |
|
|
|
Collection<String> getPackNames() throws IOException { |
|
|
|
final Collection<String> packs = new ArrayList<>(); |
|
|
|
final Collection<String> packs = new ArrayList<>(); |
|
|
|
try { |
|
|
|
try (BufferedReader br = openReader(INFO_PACKS)) { |
|
|
|
final BufferedReader br = openReader(INFO_PACKS); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
for (;;) { |
|
|
|
for (;;) { |
|
|
|
final String s = br.readLine(); |
|
|
|
final String s = br.readLine(); |
|
|
|
if (s == null || s.length() == 0) |
|
|
|
if (s == null || s.length() == 0) |
|
|
@ -978,9 +968,6 @@ public class TransportHttp extends HttpTransport implements WalkTransport, |
|
|
|
packs.add(s.substring(2)); |
|
|
|
packs.add(s.substring(2)); |
|
|
|
} |
|
|
|
} |
|
|
|
return packs; |
|
|
|
return packs; |
|
|
|
} finally { |
|
|
|
|
|
|
|
br.close(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch (FileNotFoundException err) { |
|
|
|
} catch (FileNotFoundException err) { |
|
|
|
return packs; |
|
|
|
return packs; |
|
|
|
} |
|
|
|
} |
|
|
@ -1165,10 +1152,8 @@ public class TransportHttp extends HttpTransport implements WalkTransport, |
|
|
|
// Try to compress the content, but only if that is smaller.
|
|
|
|
// Try to compress the content, but only if that is smaller.
|
|
|
|
TemporaryBuffer buf = new TemporaryBuffer.Heap( |
|
|
|
TemporaryBuffer buf = new TemporaryBuffer.Heap( |
|
|
|
http.getPostBuffer()); |
|
|
|
http.getPostBuffer()); |
|
|
|
try { |
|
|
|
try (GZIPOutputStream gzip = new GZIPOutputStream(buf)) { |
|
|
|
GZIPOutputStream gzip = new GZIPOutputStream(buf); |
|
|
|
|
|
|
|
out.writeTo(gzip, null); |
|
|
|
out.writeTo(gzip, null); |
|
|
|
gzip.close(); |
|
|
|
|
|
|
|
if (out.length() < buf.length()) |
|
|
|
if (out.length() < buf.length()) |
|
|
|
buf = out; |
|
|
|
buf = out; |
|
|
|
} catch (IOException err) { |
|
|
|
} catch (IOException err) { |
|
|
|