我正在使用OkHttp 2.4.0。Android OkHttp addPathSegment替换斜线
HttpUrl url = new HttpUrl.Builder()
.scheme("https")
.host("www.something.com")
.addPathSegment("/api/v1/doc")
.build();
预期网址是:https://www.something.com/api/v1/doc
我得到的是:https://www.something.com%2Fapi%2Fv1%2Fdoc
的 “/”,在pathSegment被替换为 “%2F”。为什么会发生这种情况,以及如何避免这种情况,因为我得到无效的Url异常,因为Apache不允许在URL中使用“%2F”。
该方法的名称是'pathSegments'或'pathSegment'?我也很确定结果是'https:// www.something.com /%2Fapi%2Fv1%2Fdoc'不是'https:// www.something.com%2Fapi%2Fv1%2Fdoc' – Selvin