List of usage examples for com.squareup.okhttp Request urlString
public String urlString()
From source file:retrofit.MagnetCall.java
License:Apache License
private void execute(CacheOptions cacheOptions, ReliableCallOptions reliableOptions) { synchronized (this) { if (this.executed) { throw new IllegalStateException("Already executed"); }/*from w w w . ja v a 2 s . c o m*/ this.executed = true; } CallOptions options = null; if (null != cacheOptions) { options = new CallOptions(cacheOptions); } else if (null != reliableOptions) { options = new CallOptions(reliableOptions); } OkHttpCall<T> okHttpCall = (OkHttpCall<T>) call; Callback<T> callback = extractAndRemoveCallback(okHttpCall); //Wrap callback in main thread executor Callback<T> callbackInMainThread = new ExecutorCallback<>(callbackExecutor, callback); Request request = okHttpCall.getRequest(null); if (null != reliableOptions) { Set<Condition> failedPrerequisites = reliableOptions.unsatisfiedConditions(true); if (!failedPrerequisites.isEmpty()) { StringBuilder sb = new StringBuilder("Prerequisite(s) not met : "); for (Condition p : failedPrerequisites) { sb.append(p.toString()).append(","); } sb.append(")"); requestManager.saveReliableRequest(request, call, callbackInMainThread, reliableOptions, sb.toString()); return; } } if (null != options) { requestManager.saveRequestOptions(request, options); } if (isCallReady(request, options)) { call.enqueue(callbackInMainThread); } else { Log.i(TAG, "Request " + request.urlString() + " is not ready, added into pending queue"); requestManager.savePendingCall(call, callbackInMainThread, options); } }
From source file:retrofit.MagnetRestAdapter.java
License:Apache License
@Override public boolean isAuthRequired(Request request) { if ("POST".equals(request.method()) && (request.urlString().endsWith(RestConstants.APP_LOGIN_URL) || request.urlString().endsWith(RestConstants.APP_LOGIN_WITH_DEVICE_URL) || request.urlString().endsWith(RestConstants.USER_REFRESH_TOKEN_URL))) { return false; }// w ww . j a va 2 s .com return true; }
From source file:windows.webservices.utilidades.EjecutorJson.java
private <T> T ejecutarJsonGeneral(Request request, Class<? extends List> colleccion, Class<? extends Map> map, Class<?> key, Class<T> mappe) throws IOException { try {/*from w w w . j a v a 2 s . c om*/ System.out.println("enlace : " + request.urlString() + (json != null && !json.isEmpty() ? "\n body :" + json : "")); Response response = client.newCall(request).execute(); ultimoJson = response.body().string(); if (colleccion != null) { return (T) mapperToList(ultimoJson, mappe); } else if (map != null) { return (T) mapperToMap(ultimoJson, map, key, mappe); } else { if (mappe.equals(String.class)) { return (T) ultimoJson; } return mapper.readValue(ultimoJson, mappe); } } catch (IOException ex) { if ((ex instanceof JsonParseException) || (ex instanceof EOFException)) { if ((ultimoJson.contains(EXCEPTION_REPORT) || ultimoJson.contains(ERROR_REPORT) | ultimoJson.contains(INFORME_ERROR)) && ultimoJson.contains(MESSAGE) && ultimoJson.contains(DESCRIPTION)) { String title = ultimoJson.substring(ultimoJson.indexOf("<h1>") + 4, ultimoJson.indexOf("</h1>")); String[] tags = ultimoJson.split("<p>"); String msj = tags[2].substring(tags[2].indexOf("<u>") + 3, tags[2].indexOf("</u>")); String desb = tags[3].substring(tags[3].indexOf("<u>") + 3, tags[3].indexOf("</u>")); Logger.getLogger(EjecutorJson.class.getName()).log(Level.INFO, "Titulo : {0}\nMensaje : {1}\nDescripcin : {2}", new String[] { title, msj, desb }); throw new RuntimeException(); } Logger.getLogger(EjecutorJson.class.getName()).log(Level.WARNING, "No se pudo castear el siguiente jSon : \n {0}", ultimoJson); } else if (ex instanceof SocketTimeoutException) { Logger.getLogger(EjecutorJson.class.getName()).log(Level.WARNING, "Se agoto el tiempo de respuesta"); throw new SocketTimeoutException("Se agoto el tiempo de respuesta"); } else if (ex instanceof ConnectException) { Logger.getLogger(EjecutorJson.class.getName()).log(Level.WARNING, "No se pudo conectar al servidor"); throw new ConnectException("No se pudo conectar al servidor"); } else { Logger.getLogger(EjecutorJson.class.getName()).log(Level.SEVERE, null, ex); } } return null; }