List of usage examples for com.squareup.okhttp HttpUrl url
String url
To view the source code for com.squareup.okhttp HttpUrl url.
Click Source Link
From source file:com.dreamdigitizers.androidsoundcloudapi.core.Api.java
private Api(final String pClientId, final String pOauthToken) { OkHttpClient okHttpClient = new OkHttpClient(); okHttpClient.interceptors().add(new Interceptor() { @Override// ww w .ja v a 2 s.c om public Response intercept(Chain pChain) throws IOException { Request request = pChain.request(); HttpUrl.Builder builder = request.httpUrl().newBuilder(); builder.addQueryParameter("client_id", pClientId); if (!TextUtils.isEmpty(pOauthToken)) { builder.addQueryParameter("oauth_token", pOauthToken); } HttpUrl httpUrl = builder.build(); Log.d(Api.TAG, httpUrl.url().toString()); request = request.newBuilder().url(httpUrl).build(); Response response = pChain.proceed(request); String bodyString = response.body().string(); response = response.newBuilder() .body(ResponseBody.create(response.body().contentType(), bodyString)).build(); Log.d(Api.TAG, bodyString); return response; } }); Retrofit retrofit = new Retrofit.Builder().baseUrl(IApi.API_URL__BASE).client(okHttpClient) .addConverterFactory(GsonConverterFactory.create()) .addCallAdapterFactory(RxJavaCallAdapterFactory.create()).build(); this.mApi = retrofit.create(IApi.class); }
From source file:net.yatomiya.e4.util.HttpUtils.java
License:Open Source License
public static URL toURL(String str) { try {//from w w w . ja v a 2 s . co m // HttpUrl checks url more strictly than java.net.URL. HttpUrl hurl = HttpUrl.parse(str); URL url = hurl.url(); return url; } catch (Exception e) { return null; } }