public JSONObject doGet(String url) throws JSONException { HttpGet http = new HttpGet(url); try { addHeaders(http); HttpResponse rsp = client.execute(http); int ret = rsp.getStatusLine().getStatusCode(); if (ret / 200 == 1) return new JSONObject(readString(rsp.getEntity().getContent(), "UTF-8")); throw new RuntimeException("Problem " + ret + " while " + http.getMethod() + " " + readString(rsp.getEntity().getContent(), "UTF-8")); } catch (Exception ex) { throw new RuntimeException("Problem while " + http.getMethod() + ", Error:" + ex.getMessage() + ", url:" + url, ex); } finally { http.releaseConnection(); } }
public void intercept(HttpGet request, GenericUrl url) throws IOException { computeNonce(); computeTimestamp(); try { computeSignature(request.getMethod(), url); } catch (GeneralSecurityException e) { logger.error(e); IOException io = new IOException(); io.initCause(e); throw io; } request.addHeader("Authorization", getAuthorizationHeader()); }
LOGGER.info("Request: " + httpGet.getMethod() + " " + httpGet.getURI()); LOGGER.info("Response: " + response.getStatusLine() + "\n" + resStr);
LOGGER.info("Request: " + get.getMethod() + " " + get.getURI()); LOGGER.info("Response: " + response.getStatusLine() + "\n" + resStr);
if (request instanceof HttpGet) { HttpGet httpGet = (HttpGet) request; Logger.log_behavior("HTTP Method : " + httpGet.getMethod()); Logger.log_behavior("HTTP URL : " + httpGet.getURI().toString()); Header[] headers = request.getAllHeaders();
if (request instanceof HttpGet) { HttpGet httpGet = (HttpGet) request; Logger.log_behavior("HTTP Method : " + httpGet.getMethod()); Logger.log_behavior("HTTP URL : " + httpGet.getURI().toString()); Header[] headers = request.getAllHeaders();