make sure HTTP servers are able to skip the right amount
This should fix the PMD error: "Check the value returned by the skip() method of an InputStream to see if the requested number of bytes has been skipped."
This commit is contained in:
parent
a0c20a35c3
commit
103b2265ee
@ -265,7 +265,10 @@ public class LocalHTTPD extends NanoHTTPD {
|
|||||||
return (int) dataLen;
|
return (int) dataLen;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fis.skip(startFrom);
|
long skipped = fis.skip(startFrom);
|
||||||
|
if (skipped != startFrom) {
|
||||||
|
throw new IOException("unable to skip the required " + startFrom + " bytes.");
|
||||||
|
}
|
||||||
|
|
||||||
res = createResponse(Response.Status.PARTIAL_CONTENT, mime, fis);
|
res = createResponse(Response.Status.PARTIAL_CONTENT, mime, fis);
|
||||||
res.addHeader("Content-Length", String.valueOf(dataLen));
|
res.addHeader("Content-Length", String.valueOf(dataLen));
|
||||||
|
@ -303,7 +303,10 @@ public class BluetoothServer extends Thread {
|
|||||||
return (int) dataLen;
|
return (int) dataLen;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fis.skip(startFrom);
|
long skipped = fis.skip(startFrom);
|
||||||
|
if (skipped != startFrom) {
|
||||||
|
throw new IOException("unable to skip the required " + startFrom + " bytes.");
|
||||||
|
}
|
||||||
|
|
||||||
res = createResponse(NanoHTTPD.Response.Status.PARTIAL_CONTENT, mime, fis);
|
res = createResponse(NanoHTTPD.Response.Status.PARTIAL_CONTENT, mime, fis);
|
||||||
res.addHeader("Content-Length", String.valueOf(dataLen));
|
res.addHeader("Content-Length", String.valueOf(dataLen));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user