Skip to content

404 - Not Found - Issue 19#82

Merged
helenahalldiniths merged 7 commits into
mainfrom
issue-19
Feb 10, 2022
Merged

404 - Not Found - Issue 19#82
helenahalldiniths merged 7 commits into
mainfrom
issue-19

Conversation

@ToniKaru

@ToniKaru ToniKaru commented Feb 8, 2022

Copy link
Copy Markdown
Contributor

If a file/url is not found, an exception created and is logged.

Definitely can use a bit of refactoring here and there.

@ToniKaru ToniKaru requested a review from joejoh84 February 8, 2022 14:00
@ToniKaru

ToniKaru commented Feb 8, 2022

Copy link
Copy Markdown
Contributor Author

I did miss adding tests for the code I added in ClientHandler, including logging and the if else. I will be working on that for a bit.

Edit: Nevermind. I will wait for comments first as a ClientHandlerTest is already in the works.

@ToniKaru ToniKaru marked this pull request as draft February 8, 2022 14:16
@ToniKaru ToniKaru marked this pull request as ready for review February 8, 2022 14:39
@ToniKaru ToniKaru changed the title Issue 19 404 - Not Found - Issue 19 Feb 8, 2022

@joejoh84 joejoh84 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but i am unsure about expected behavior when 404 error page is not present in webroot. Should the server write out default message here? now it just get stuck in loading. I believe its due to ClientHandler trying write response[1]

FileRequestHandler:
public byte[][] writeResponse(String responseCode) { String response = "HTTP/1.1 " + responseCode + " \r\nConnection: Closed\r\n\r\n"; return new byte[][]{response.getBytes()}; }

ClientHandler:
try { fileInfo = fileRequestHandler.handleRequest(input); response = fileRequestHandler.writeResponse(fileInfo); } catch (FileNotFoundException e){ LOGGER.error("File not found: {}", e.getRequestPath()); response = getFileNotFoundResponse(fileRequestHandler, e); } out.write(response[0]); out.write(response[1]);

@FelixJacobsen FelixJacobsen self-requested a review February 9, 2022 12:05

@FelixJacobsen FelixJacobsen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good, I like the usage of a Enum as "Response.Status" is defined.

I agree with @joejoh84, there should be some kind of default message to prevent it getting stuck in loading. But the code should do what it is supoposed to do and solve the issue.

@helenahalldiniths helenahalldiniths merged commit 48785f6 into main Feb 10, 2022
@helenahalldiniths helenahalldiniths deleted the issue-19 branch February 10, 2022 08:26
@kappsegla kappsegla linked an issue Feb 11, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

404 - Not found

4 participants