/** * Removes query parameter from an Uri, if present. * * @param uri The uri. * @param queryParameterName The name of the query parameter. * @return The uri without the query parameter. */ public static Uri removeQueryParameter(Uri uri, String queryParameterName) { Uri.Builder builder = uri.buildUpon(); builder.clearQuery(); for (String key : uri.getQueryParameterNames()) { if (!key.equals(queryParameterName)) { for (String value : uri.getQueryParameters(key)) { builder.appendQueryParameter(key, value); } } } return builder.build(); }
if(!TextUtils.isEmpty(mBundleUrl)){ try { performance.args= Uri.parse(mBundleUrl).buildUpon().clearQuery().toString(); } catch (Exception e) { performance.args=pageName;
/** * @return the emitter uri */ public String getEmitterUri() { return this.uriBuilder.clearQuery().build().toString(); }
/** * Builds an OkHttp GET request which is ready * to be executed. * @param payload The payload to be sent in the * request. * @return an OkHttp request object */ @SuppressWarnings("unchecked") private Request requestBuilderGet(Payload payload) { addStmToEvent(payload, ""); // Clear the previous query uriBuilder.clearQuery(); // Build the request query HashMap hashMap = (HashMap) payload.getMap(); for (String key : (Iterable<String>) hashMap.keySet()) { String value = (String) hashMap.get(key); uriBuilder.appendQueryParameter(key, value); } // Build the request String reqUrl = uriBuilder.build().toString(); return new Request.Builder() .url(reqUrl) .get() .build(); }
/** * 查找html缓存 * * @param url * @return */ public CacheEntry findHtmlCache(String url) { if (TextUtils.isEmpty(url)) { return null; } // html地址需要去掉参数 url = Uri.parse(url).buildUpon().clearQuery().build().toString(); if (!checkUrl(url)) { return null; } CacheEntry result = null; // 遍历外部缓存 for (ICache cache : mCaches) { result = cache.findCache(url); if (null != result && result.isValid()) { return result; } } // 遍历内部缓存 result = mInternalHtmlCache.findCache(url); return result; }
public static OAuthTokensResponse completeAuthorization(Context context, String clientId, String clientSecret, Uri redirectUri) throws UnauthorizedException, IOException { String csrfToken = redirectUri.getQueryParameter("state"); String authCode = redirectUri.getQueryParameter("code"); if (csrfToken == null || !csrfToken.equals(getLoginCSRFToken(context))) { throw new UnauthorizedException("CSRF Detected!"); } else if (authCode == null) { String errorDescription = redirectUri.getQueryParameter("error_description"); throw new UnauthorizedException(errorDescription); } else { try { Coinbase coinbase = new CoinbaseBuilder().build(); Uri redirectUriWithoutQuery = redirectUri.buildUpon().clearQuery().build(); return coinbase.getTokens(clientId, clientSecret, authCode, redirectUriWithoutQuery.toString()); } catch (CoinbaseException ex) { throw new UnauthorizedException(ex.getMessage()); } } }