InputStream in = null;
/**
* Attempts to open a FileInputStream on the file, this is used for
* reading it's content.
*/
HttpHeader header = new HttpHeader(socket, f.getPath());
try {
in = new BufferedInputStream(new FileInputStream(f));
Log.fine("200: %s", f.getPath());
} catch (FileNotFoundException e) {
Log.fine("404: %s", get);
try {
socketOut.write(header.get404());
} catch (IOException e1) {
Log.fine("Unable to write 404 to output stream.");
}
return;
}
try {
socketOut.write(header.get200());
} catch (IOException e1) {
Log.info("Unable to write header to output stream for: %s", getIp());
}
try {
socketOut.write(header.getContentLength(in.available()));
socketOut.write(CRLF.getBytes());
} catch (IOException e1) {
Log.info("Unable to write content length to the header for: %s",
getIp());
e1.printStackTrace();