updated clientHandler for 501 response and httpParser#224
updated clientHandler for 501 response and httpParser#224Charlottehenriksson wants to merge 2 commits intomainfrom
Conversation
Qodana Community for JVMIt seems all right 👌 No new problems were found according to the checks applied 💡 Qodana analysis was run in the pull request mode: only the changed files were checked View the detailed Qodana reportTo be able to view the detailed Qodana report, you can either:
To get - name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2023.3.1
with:
upload-result: trueContact Qodana teamContact us at qodana-support@jetbrains.com
|
ajohnsson95
left a comment
There was a problem hiding this comment.
Seems to be missing method id HttpParser.java other than that looks fine to me
There was a problem hiding this comment.
Seems to be missing a getRequestMethod that is being called at ClientHandler.java Line 64
There was a problem hiding this comment.
I have added a getRequestMethod and it seems to be working now, thanks for the feedback!
ajohnsson95
left a comment
There was a problem hiding this comment.
Method looks to be called correctly.
|
|
||
| private void handleIOException(IOException e) { | ||
| if (e.getMessage().contains("500")) | ||
| LOGGER.error(ResponseCode.HTTP_RESPONSE_STATUS_CODES); | ||
| else | ||
| LOGGER.error(e.getMessage()); | ||
| } |
There was a problem hiding this comment.
This method is never used and can be removed?
| String method = HttpParser.getRequestMethod(input); | ||
| if (!HttpParser.isMethodSupported(method)) { | ||
| return get501Response(); | ||
| } | ||
|
|
There was a problem hiding this comment.
Since this code is added in the getResponse method it will not be used for requests handled before this point, i.e. isCoffeeRequest. But maybe it is the check for coffeerequest and return of 418 response that should be moved into the getresponse method instead to be a part of this check.
| FileInfo fileInfo = new FileInfo(Path.of("/"), description.getBytes()); | ||
| return fileRequestHandler.writeResponse(fileInfo, description); |
There was a problem hiding this comment.
Should we really try to return root path that will be translated into index.html? Check Teapot.write418Response() for how to make a response in code without returning a file.
There was a problem hiding this comment.
The problem with returning a file as a response is that it can include sensitive information.
included HEAD in list of supported methods, added new method isMethodSupported.
updated the getResponse method, and added new method get501Response