@Override
	public void respond() {
		File file = new File(Main.webroot + path); // find file within webroot
		if(file.isDirectory()) file = new File(
				Main.webroot + path + File.separator + Main.defaultFile);
		
		try { // attepmt the normal case: file exists
			FileInputStream in = new FileInputStream(file);
			
			status(200); // OK
			
			header("Date", rfcDate());
			header("Server", Main.SERVER_STRING);
			header("Connection", "close"); // no keep-alive
			
			byte[] buffer = new byte[1024];
			int bytes = 0;
			
			// copy bytes from the file to the socket.
			while((bytes = in.read(buffer)) != -1)
				data(buffer, bytes);
			
			in.close();
			
		} catch (FileNotFoundException e) {	// if file does not exist.
			status(404); // send 404 Not Found
			data("404 Not Found");
		} catch (IOException e) {
			e.printStackTrace();
		}
		finally {
			close();
		}
	}