Skip to content

Conversation

tcheeric
Copy link
Owner

Summary

  • refactor Nip05Validator to use java.net.http.HttpClient
  • update HTTP error handling
  • keep existing Nip05Validator tests

Testing

  • mvn -q verify

https://chatgpt.com/codex/tasks/task_b_688903761ec883318db857dc64aed1ef

Copilot

This comment was marked as outdated.

…tor.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@tcheeric tcheeric requested a review from Copilot July 29, 2025 17:40
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the Nip05Validator class to use the modern java.net.http.HttpClient API instead of the legacy HttpURLConnection for making HTTP requests. The change modernizes the HTTP client implementation while maintaining the same validation functionality.

  • Replaced HttpURLConnection with HttpClient for HTTP requests
  • Updated error handling to use HttpClient exceptions and proper thread interruption handling
  • Simplified the HTTP response reading logic by using HttpResponse.BodyHandlers.ofString()

Comment on lines +84 to 86
StringBuilder content = new StringBuilder(response.body());

// (2)
String pubKey = getPublicKey(content, localPart);
Copy link
Preview

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

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

Creating a StringBuilder from response.body() is unnecessary since response.body() already returns a String. You can directly pass response.body() to getPublicKey() method.

Copilot uses AI. Check for mistakes.

.replace("<domain>", domain)
.replace("<localPart>", localPart);

HttpClient client = HttpClient.newHttpClient();
Copy link
Preview

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

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

Creating a new HttpClient instance for each validation request is inefficient. Consider making HttpClient a static final field or instance field to reuse the same client across multiple validation calls.

Copilot uses AI. Check for mistakes.

@tcheeric tcheeric merged commit af0197c into develop Jul 29, 2025
@tcheeric tcheeric deleted the k4pgmu-codex/update-nip05validator-to-use-httpclient branch July 29, 2025 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant