private int getContentLength(InputStream in)
throws IOException
{
HttpHeaders headers = new HttpHeaders(in);
if(!headers.getCommand().equals(POST)) {
throw new IOException("Expected " + POST + "-Command");
}
if(!headers.getUri().equals(XCP)) {
throw new IOException("Expected uri " + XCP);
}
int length = 0;
String s = headers.getHeader(CL);
try {
length = Integer.parseInt(s);
} catch(Exception ex) {
throw new IOException("Failed reading content-length: '" + s + "'");
}