Package io.karatelabs.http
Class HttpUtils
java.lang.Object
io.karatelabs.http.HttpUtils
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringBuild a URI with query parameters from a path and params map.static StringextractPath(String uri) Extract just the path portion from a URI (strips query string).static StringextractQueryString(String uri) Extract just the query string from a URI (without the leading '?').static ObjectfromBytes(byte[] bytes, boolean strict, io.karatelabs.common.ResourceType resourceType) static ObjectfromString(String raw, boolean strict, io.karatelabs.common.ResourceType resourceType) static StringnormaliseUriPath(String uri) static CharsetparseContentTypeCharset(String mimeType) parseContentTypeParams(String mimeType) static io.karatelabs.common.Pair<Object> parsePathAndParams(String uri) Parse a URI path that may contain query parameters.parseQueryParams(String uri) Parse query string parameters from a URI.static io.karatelabs.common.Pair<String> parseUriIntoUrlBaseAndPath(String rawUri) parseUriPattern(String pattern, String url)
-
Field Details
-
ZERO_BYTES
public static final byte[] ZERO_BYTES -
MEGABYTE
public static final int MEGABYTE- See Also:
-
-
Constructor Details
-
HttpUtils
public HttpUtils()
-
-
Method Details
-
parseContentTypeCharset
-
parseContentTypeParams
-
parseUriPattern
-
normaliseUriPath
-
parseUriIntoUrlBaseAndPath
-
fromBytes
public static Object fromBytes(byte[] bytes, boolean strict, io.karatelabs.common.ResourceType resourceType) -
fromString
-
parsePathAndParams
Parse a URI path that may contain query parameters. Returns a Pair where left is the path (without query string) and right is the params map.Examples: - "/test?name=john" -> Pair.of("/test", {name: [john]}) - "/test" -> Pair.of("/test", {}) - "/api/users?id=1invalid input: '&id'=2" -> Pair.of("/api/users", {id: [1, 2]})
-
buildUri
Build a URI with query parameters from a path and params map.Example: buildUri("/test", Map.of("name", List.of("john"))) -> "/test?name=john"
-
extractPath
Extract just the path portion from a URI (strips query string). -
extractQueryString
Extract just the query string from a URI (without the leading '?'). Returns null if no query string present. -
parseQueryParams
Parse query string parameters from a URI. Returns empty map if no query string present.
-