Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static Map<String, String> buildWebSocketHeaders(
String apiKey, boolean isSecurityCheck, String workspace, Map<String, String> customHeaders)
throws NoApiKeyException {
Map<String, String> headers = new HashMap<>();
headers.put("Authorization", "bearer " + ApiKey.getApiKey(apiKey));
headers.put("Authorization", "Bearer " + ApiKey.getApiKey(apiKey));

Choose a reason for hiding this comment

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

medium

To improve maintainability and avoid duplicating string literals, consider extracting "Bearer " into a class-level constant. This string is also used in the buildHttpHeaders method on line 51. Creating a constant like private static final String AUTH_BEARER_PREFIX = "Bearer "; at the class level would centralize this value and make future changes easier.

headers.put("user-agent", userAgent());
if (workspace != null && !workspace.isEmpty()) {
headers.put("X-DashScope-WorkSpace", workspace);
Expand Down