Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated clientHandler for 501 response and httpParser #224

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Charlottehenriksson
Copy link

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

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

@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

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

@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.

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
3 participants