File tree Expand file tree Collapse file tree 2 files changed +3
-24
lines changed
main/java/spring/memewikibe/common/util
test/java/spring/memewikibe/common/util Expand file tree Collapse file tree 2 files changed +3
-24
lines changed Original file line number Diff line number Diff line change @@ -47,30 +47,11 @@ public static byte[] downloadBytes(String url) throws IOException {
4747 }
4848
4949 public static String detectMimeType (String imageUrl , byte [] data ) {
50- // Try by HTTP response header
51- try {
52- URI uri = new URI (imageUrl );
53- HttpRequest request = HttpRequest .newBuilder ()
54- .uri (uri )
55- .timeout (Duration .ofSeconds (5 ))
56- .method ("HEAD" , HttpRequest .BodyPublishers .noBody ())
57- .build ();
58-
59- HttpResponse <Void > response = HTTP_CLIENT .send (request , HttpResponse .BodyHandlers .discarding ());
60- String contentType = response .headers ().firstValue ("Content-Type" ).orElse (null );
61- if (StringUtils .hasText (contentType )) {
62- // Content-Type might include charset, so extract only the MIME type
63- return contentType .split (";" )[0 ].trim ();
64- }
65- } catch (Exception ignored ) {
66- // If HEAD request fails, continue with other methods
67- }
68-
69- // Try by stream content sniffing using legacy method (still works for content detection)
50+ // Prioritize byte signature analysis (fastest and most reliable)
7051 String guessed = guessContentTypeFromBytes (data );
7152 if (StringUtils .hasText (guessed )) return guessed ;
72-
73- // Fallback by extension
53+
54+ // Fallback to extension-based detection
7455 return getMimeTypeByExtension (imageUrl );
7556 }
7657
Original file line number Diff line number Diff line change @@ -106,8 +106,6 @@ void zset_is_not_thread_safe_mixed_operations() throws InterruptedException {
106106
107107 // 이 assertion은 자주 실패함 (내부 일관성이 깨짐을 증명)
108108 // dictSize와 skipSize가 다를 수 있음
109- System .out .println ("Dict size: " + dictSize + ", Skip size: " + skipSize );
110-
111109 // 최소한 하나 이상의 데이터가 있어야 함
112110 then (dictSize + skipSize ).isGreaterThan (0 );
113111 }
You can’t perform that action at this time.
0 commit comments