Update upload to debug the content if incorrect properly.

This commit is contained in:
dordsor21 2020-04-18 17:53:45 +01:00
parent 165614efe9
commit af951ac11c

View file

@ -81,6 +81,7 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.Scanner;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.function.Function; import java.util.function.Function;
@ -222,22 +223,12 @@ public class MainUtil {
writer.append(CRLF).flush(); writer.append(CRLF).flush();
writer.append("--" + boundary + "--").append(CRLF).flush(); writer.append("--" + boundary + "--").append(CRLF).flush();
} }
try (Reader response = new InputStreamReader(con.getInputStream(), String content;
StandardCharsets.UTF_8)) { try (Scanner scanner = new Scanner(con.getInputStream()).useDelimiter("\\A")) {
final char[] buffer = new char[256]; content = scanner.next().trim();
final StringBuilder result = new StringBuilder(); }
while (true) { if (!content.startsWith("<")) {
final int r = response.read(buffer); PlotSquared.debug(content);
if (r < 0) {
break;
}
result.append(buffer, 0, r);
}
if (!result.toString().startsWith("Success")) {
PlotSquared.debug(result);
}
} catch (IOException e) {
e.printStackTrace();
} }
int responseCode = ((HttpURLConnection) con).getResponseCode(); int responseCode = ((HttpURLConnection) con).getResponseCode();
if (responseCode == 200) { if (responseCode == 200) {