List of usage examples for com.squareup.okhttp Protocol HTTP_1_0
Protocol HTTP_1_0
To view the source code for com.squareup.okhttp Protocol HTTP_1_0.
Click Source Link
From source file:alberto.avengers.model.rest.utils.interceptors.HttpLoggingInterceptor.java
License:Apache License
private static String protocol(Protocol protocol) { return protocol == Protocol.HTTP_1_0 ? "HTTP/1.0" : "HTTP/1.1"; }
From source file:com.vavian.mockretrofitrequests.rest.service.FakeInterceptor.java
License:Apache License
@Override public Response intercept(Chain chain) throws IOException { Response response = null;/*from w w w . j a v a 2s .co m*/ if (BuildConfig.DEBUG) { Log.d(TAG, "---- DEBUG --- DEBUG -- DEBUG - DEBUG -- DEBUG --- DEBUG ----"); Log.d(TAG, "---- FAKE SERVER RESPONSES ----"); String responseString; // Get Request URI. final URI uri = chain.request().uri(); Log.d(TAG, "---- Request URL: " + uri.toString()); // Get Query String. final String query = uri.getQuery(); // Parse the Query String. final String[] parsedQuery = query.split("="); if (parsedQuery[0].equalsIgnoreCase("id") && parsedQuery[1].equalsIgnoreCase("1")) { responseString = TEACHER_ID_1; } else if (parsedQuery[0].equalsIgnoreCase("id") && parsedQuery[1].equalsIgnoreCase("2")) { responseString = TEACHER_ID_2; } else { responseString = ""; } response = new Response.Builder().code(200).message(responseString).request(chain.request()) .protocol(Protocol.HTTP_1_0) .body(ResponseBody.create(MediaType.parse("application/json"), responseString.getBytes())) .addHeader("content-type", "application/json").build(); Log.d(TAG, "---- DEBUG --- DEBUG -- DEBUG - DEBUG -- DEBUG --- DEBUG ----"); } else { response = chain.proceed(chain.request()); } return response; }