Skip to content

Commit

Permalink
Remove HttpCore dependency, WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
HardNorth committed Jan 10, 2024
1 parent 2af16a6 commit 4f120c7
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@
package com.epam.reportportal.formatting.http;

import javax.annotation.Nullable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@SuppressWarnings("unused")
public class ContentType {
private static final Pattern HTTP_HEADER_DELIMITER_PATTERN = Pattern.compile("[=;,]");

// Binary types
public static final String APPLICATION_OCTET_STREAM = "application/octet-stream";
Expand Down Expand Up @@ -62,6 +65,14 @@ public static String parse(@Nullable String contentType) {
if (contentType == null || contentType.trim().isEmpty()) {
return null;
}
return null;
String trimmed = contentType.trim();
Matcher m = HTTP_HEADER_DELIMITER_PATTERN.matcher(trimmed);
String mimeType;
if (m.find()) {
mimeType = trimmed.substring(0, m.start());
} else {
mimeType = trimmed;
}
return mimeType.isEmpty() ? null : mimeType;
}
}

0 comments on commit 4f120c7

Please sign in to comment.