static CassieqCredentials signedQueryString(String queryAuth) { final Map<String, String> queryAuthParams = Splitter.on('&').omitEmptyStrings().withKeyValueSeparator('=').split(queryAuth); return request -> { final HttpUrl httpUrl = request.httpUrl(); HttpUrl.Builder newUrlBuilder = httpUrl.newBuilder(); for (Map.Entry<String, String> entry : queryAuthParams.entrySet()) { newUrlBuilder = newUrlBuilder.addQueryParameter(entry.getKey(), entry.getValue()); } return request.newBuilder().url(newUrlBuilder.build()).build(); }; }
/** * 构建URL * * @param pathUrl * @param params * @return */ private HttpUrl buildUrl(String pathUrl, Map<String, Object> params) { String fullUrl = ""; if (pathUrl.contains(this.baseUrl)) { fullUrl = pathUrl; } else { fullUrl = this.baseUrl + pathUrl; } HttpUrl.Builder hb = HttpUrl.parse(fullUrl).newBuilder(); if (null != params) { Set<String> keys = params.keySet(); for (String key : keys) { hb.addQueryParameter(key, params.get(key) + ""); } } HttpUrl httpUrl = hb.build(); // Timber.i("fullUrl:%s host:%s, port:%s", fullUrl, httpUrl.host(), httpUrl.port()); return httpUrl; }