|
|
@ -42,10 +42,10 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
package org.eclipse.jgit.lfs.server.fs; |
|
|
|
package org.eclipse.jgit.lfs.server.fs; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static java.nio.charset.StandardCharsets.UTF_8; |
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
import static org.junit.Assert.assertEquals; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedInputStream; |
|
|
|
import java.io.BufferedInputStream; |
|
|
|
import java.io.ByteArrayOutputStream; |
|
|
|
|
|
|
|
import java.io.FileNotFoundException; |
|
|
|
import java.io.FileNotFoundException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.InputStream; |
|
|
|
import java.io.InputStream; |
|
|
@ -80,6 +80,7 @@ import org.eclipse.jgit.lfs.lib.Constants; |
|
|
|
import org.eclipse.jgit.lfs.lib.LongObjectId; |
|
|
|
import org.eclipse.jgit.lfs.lib.LongObjectId; |
|
|
|
import org.eclipse.jgit.lfs.test.LongObjectIdTestUtils; |
|
|
|
import org.eclipse.jgit.lfs.test.LongObjectIdTestUtils; |
|
|
|
import org.eclipse.jgit.util.FileUtils; |
|
|
|
import org.eclipse.jgit.util.FileUtils; |
|
|
|
|
|
|
|
import org.eclipse.jgit.util.IO; |
|
|
|
import org.junit.After; |
|
|
|
import org.junit.After; |
|
|
|
import org.junit.Before; |
|
|
|
import org.junit.Before; |
|
|
|
|
|
|
|
|
|
|
@ -189,15 +190,17 @@ public abstract class LfsServerTest { |
|
|
|
if (statusLine.getStatusCode() >= 400) { |
|
|
|
if (statusLine.getStatusCode() >= 400) { |
|
|
|
String error; |
|
|
|
String error; |
|
|
|
try { |
|
|
|
try { |
|
|
|
BufferedInputStream bis = new BufferedInputStream( |
|
|
|
ByteBuffer buf = IO.readWholeStream(new BufferedInputStream( |
|
|
|
response.getEntity().getContent()); |
|
|
|
response.getEntity().getContent()), 1024); |
|
|
|
ByteArrayOutputStream buf = new ByteArrayOutputStream(); |
|
|
|
if (buf.hasArray()) { |
|
|
|
int result = bis.read(); |
|
|
|
error = new String(buf.array(), |
|
|
|
while (result != -1) { |
|
|
|
buf.arrayOffset() + buf.position(), buf.remaining(), |
|
|
|
buf.write((byte) result); |
|
|
|
UTF_8); |
|
|
|
result = bis.read(); |
|
|
|
} else { |
|
|
|
|
|
|
|
final byte[] b = new byte[buf.remaining()]; |
|
|
|
|
|
|
|
buf.duplicate().get(b); |
|
|
|
|
|
|
|
error = new String(b, UTF_8); |
|
|
|
} |
|
|
|
} |
|
|
|
error = buf.toString(); |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
} catch (IOException e) { |
|
|
|
error = statusLine.getReasonPhrase(); |
|
|
|
error = statusLine.getReasonPhrase(); |
|
|
|
} |
|
|
|
} |
|
|
|