src/ErrorRequest.java
@Override
	public void ReturnResponse() throws IOException {
		OutputStream outputStream = m_Socket.getOutputStream();
		StringBuilder responseString = new StringBuilder();
		responseString.append(m_Header);
		
		byte[] content = Tools.ReadFile(new File(m_FilePath));
		HashMap<String, String> defaultHeaders = Tools.SetupResponseHeaders(content, m_Type);
		for(String header : defaultHeaders.keySet()) {
			responseString.append(header).append(": ").append(defaultHeaders.get(header)).append("\r\n");
		}
		
		System.out.println(responseString);
		responseString.append("\r\n");
		
		try {
			outputStream.write(responseString.toString().getBytes());
			outputStream.write(content);
			outputStream.flush();
			outputStream.close();
		} catch (IOException e) {
			System.out.println("No socket to write the respone to.");
		}
	}
/*
	 * Build the response for the received error
	 */
Build the response for the received error
Build the response for the received error
@Override
	public void ReturnResponse() throws IOException {
		OutputStream outputStream = m_Socket.getOutputStream();
		StringBuilder responseString = new StringBuilder();
		responseString.append(m_Header);
		byte[] content = Tools.ReadFile(new File(m_FilePath));
		HashMap<String, String> defaultHeaders = Tools.SetupResponseHeaders(content, m_Type);
		for(String header : defaultHeaders.keySet()) {
			responseString.append(header).append(": ").append(defaultHeaders.get(header)).append("\r\n");
		}
		System.out.println(responseString);
		responseString.append("\r\n");
		try {
			outputStream.write(responseString.toString().getBytes());
			outputStream.write(content);
			outputStream.flush();
			outputStream.close();
		} catch (IOException e) {
			System.out.println("No socket to write the respone to.");
		}
	}
@ Override public void ReturnResponse ( ) throws IOException { OutputStream outputStream = m_Socket . getOutputStream ( ) ; StringBuilder responseString = new StringBuilder ( ) ; responseString . append ( m_Header ) ; byte [ ] content = Tools . ReadFile ( new File ( m_FilePath ) ) ; HashMap < String , String > defaultHeaders = Tools . SetupResponseHeaders ( content , m_Type ) ; for ( String header : defaultHeaders . keySet ( ) ) { responseString . append ( header ) . append ( ": " ) . append ( defaultHeaders . get ( header ) ) . append ( "\r\n" ) ; } System . out . println ( responseString ) ; responseString . append ( "\r\n" ) ; try { outputStream . write ( responseString . toString ( ) . getBytes ( ) ) ; outputStream . write ( content ) ; outputStream . flush ( ) ; outputStream . close ( ) ; } catch ( IOException e ) { System . out . println ( "No socket to write the respone to." ) ; } }
Build the response for the received error
Build the response for the received error