Code: Select all
public static void main(String[] args) {
try {
HttpURLConnection conn = (HttpURLConnection) new URL("http://....").openConnection();
conn.setRequestMethod("GET");
conn.connect();
if (conn.getResponseCode() != 200)
throw new RuntimeException("Failed to connect: " + conn.getResponseCode());
String ct = conn.getHeaderField("Content-Type");
String bnd = "--" + ct.split("boundary=")[1];
System.out.println("Boundary is: " + bnd);
try (InputStream is = conn.getInputStream()) {
MultipartStream multi = new MultipartStream(is, bnd.getBytes(StandardCharsets.ISO_8859_1), 4096, null);
boolean next = multi.skipPreamble(); // STUCK HERE
while (next) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
multi.readBodyData(baos);
processFrame(baos);
next = multi.readBoundary();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
[img]https:/ /i.sstatic.net/f5HT7lT6.png[/img]
und dann am Ende des ersten Frames kann ich Folgendes sehen:
< img alt="Ende des ersten Frames" src="https://i.sstatic.net/8At8OdTK.png" />
Dies wiederholt sich wie erwartet.