square / okhttp

Square’s meticulous HTTP client for the JVM, Android, and GraalVM.

Home Page:https://square.github.io/okhttp/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Request bug

YFCOM opened this issue · comments

commented

public Request.Builder url(String url) {
if (url == null) {
throw new NullPointerException("url == null");
} else {
if (url.regionMatches(true, 0, "ws:", 0, 3)) {
url = "http:" + url.substring(3);
} else if (url.regionMatches(true, 0, "wss:", 0, 4)) {
url = "https:" + url.substring(4);
}

            HttpUrl parsed = HttpUrl.parse(url);
            if (parsed == null) {
                throw new IllegalArgumentException("unexpected url: " + url);
            } else {
                return this.url(parsed);
            }
        }
    }

HttpUrl parsed = HttpUrl.parse(url); when url is a string like "/et/appCenterEventTracking" will throw IllegalArgumentException("unexpected url: " + url). This is unreasonable,this issue is v3.8.1

This is by design, HttpUrl is a strict implementation of Http URLs, not a general URL/URI class that can handle anything.