Repository: apache/dubbo
File: dubbo-remoting/dubbo-remoting-http12/src/main/java/org/apache/dubbo/remoting/http12/HttpUtils.java (Java)

Code before:
        }
        if (statusCode == 500) {
            return HttpStatus.INTERNAL_SERVER_ERROR.getStatusString();
        }
        return Integer.toString(statusCode);
    }

    public static List<HttpCookie> decodeCookies(String value) {
        List<HttpCookie> cookies = new ArrayList<>();
        for (Cookie c : ServerCookieDecoder.LAX.decodeAll(value)) {
            cookies.add(new HttpCookie(c.name(), c.value()));
        }
        return cookies;
    }

    public static String encodeCookie(HttpCookie cookie) {
        DefaultCookie c = new DefaultCookie(cookie.name(), cookie.value());
        c.setPath(cookie.path());
        c.setDomain(cookie.domain());
        c.setMaxAge(cookie.maxAge());
        c.setSecure(cookie.secure());
        c.setHttpOnly(cookie.httpOnly());
        c.setSameSite(SameSite.valueOf(cookie.sameSite()));
        return ServerCookieEncoder.LAX.encode(c);
    }

    public static List<String> parseAccept(String header) {
        if (header == null) {
            return new ArrayList<>();
        }
        List<Item<String>> mediaTypes = new ArrayList<>();
        for (String item : StringUtils.tokenize(header, ',')) {
            int index = item.indexOf(';');
            mediaTypes.add(new Item<>(StringUtils.substring(item, 0, index), parseQuality(item, index)));
        }
        return Item.sortAndGet(mediaTypes);
    }

    public static float parseQuality(String expr, int index) {
        float quality = 1.0F;
        if (index != -1) {
            int qStart = expr.indexOf("q=", index + 1);
            if (qStart != -1) {
                qStart += 2;
                int qEnd = expr.indexOf(',', qStart);
                String qString = qEnd == -1
                        ? expr.substring(qStart)
                        : expr.substring(qStart, qEnd).trim();
                try {
                    quality = Float.parseFloat(qString);
                } catch (NumberFormatException ignored) {

Review comment (performance):
A tip, do not use split as it scans and slices the whole string and checks for regexp, use indexOf(char) for best performance.

Code after:
        }
        if (statusCode == 500) {
            return HttpStatus.INTERNAL_SERVER_ERROR.getStatusString();
        }
        return Integer.toString(statusCode);
    }

    public static List<HttpCookie> decodeCookies(String value) {
        List<HttpCookie> cookies = new ArrayList<>();
        for (Cookie c : ServerCookieDecoder.LAX.decodeAll(value)) {
            cookies.add(new HttpCookie(c.name(), c.value()));
        }
        return cookies;
    }

    public static String getCharsetFromContentType(String contentType) {
        String charset = null;
        if (contentType == null) {
            charset = StringUtils.EMPTY_STRING;
        } else {
            int index = contentType.lastIndexOf(CHARSET_PREFIX);
            if (index == -1) {
                charset = StringUtils.EMPTY_STRING;
            } else {
                charset = contentType.substring(index + CHARSET_PREFIX.length()).trim();
                charset = charset.split(";")[0];
            }
        }
        return charset;
    }

    public static String encodeCookie(HttpCookie cookie) {
        DefaultCookie c = new DefaultCookie(cookie.name(), cookie.value());
        c.setPath(cookie.path());
        c.setDomain(cookie.domain());
        c.setMaxAge(cookie.maxAge());
        c.setSecure(cookie.secure());
        c.setHttpOnly(cookie.httpOnly());
        c.setSameSite(SameSite.valueOf(cookie.sameSite()));
        return ServerCookieEncoder.LAX.encode(c);
    }

    public static List<String> parseAccept(String header) {
        if (header == null) {
            return new ArrayList<>();
        }
        List<Item<String>> mediaTypes = new ArrayList<>();
        for (String item : StringUtils.tokenize(header, ',')) {
            int index = item.indexOf(';');
            mediaTypes.add(new Item<>(StringUtils.substring(item, 0, index), parseQuality(item, index)));
        }