Skip to content

updated clientHandler for 501 response and httpParser#224

Open
Charlottehenriksson wants to merge 2 commits intomainfrom
client/Error501-94
Open

updated clientHandler for 501 response and httpParser#224
Charlottehenriksson wants to merge 2 commits intomainfrom
client/Error501-94

Conversation

@Charlottehenriksson
Copy link

included HEAD in list of supported methods, added new method isMethodSupported.
updated the getResponse method, and added new method get501Response

@github-actions
Copy link

github-actions bot commented Feb 16, 2024

Qodana Community for JVM

It 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 report

To be able to view the detailed Qodana report, you can either:

  1. Register at Qodana Cloud and configure the action
  2. Use GitHub Code Scanning with Qodana
  3. Host Qodana report at GitHub Pages
  4. Inspect and use qodana.sarif.json (see the Qodana SARIF format for details)

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/qodana-action@v2023.3.1
        with:
          upload-result: true
Contact Qodana team

Contact us at qodana-support@jetbrains.com

Copy link
Contributor

@ajohnsson95 ajohnsson95 left a comment

Choose a reason for hiding this comment

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

Seems to be missing method id HttpParser.java other than that looks fine to me

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems to be missing a getRequestMethod that is being called at ClientHandler.java Line 64

Choose a reason for hiding this comment

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

I have added a getRequestMethod and it seems to be working now, thanks for the feedback!

Copy link
Contributor

@ajohnsson95 ajohnsson95 left a comment

Choose a reason for hiding this comment

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

Method looks to be called correctly.

Comment on lines +99 to +105

private void handleIOException(IOException e) {
if (e.getMessage().contains("500"))
LOGGER.error(ResponseCode.HTTP_RESPONSE_STATUS_CODES);
else
LOGGER.error(e.getMessage());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This method is never used and can be removed?

Comment on lines +64 to +68
String method = HttpParser.getRequestMethod(input);
if (!HttpParser.isMethodSupported(method)) {
return get501Response();
}

Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Comment on lines +85 to +86
FileInfo fileInfo = new FileInfo(Path.of("/"), description.getBytes());
return fileRequestHandler.writeResponse(fileInfo, description);
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

The problem with returning a file as a response is that it can include sensitive information.

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.

Request types not supported should return error 501

4 participants