Exemple #1
0
 byte[] getByteBodyContents() {
   if (bytePayload != null) return bytePayload;
   String body = null;
   if (payload != null) {
     body = payload;
   } else if (files.isEmpty()) {
     body = URLUtils.formURLEncodeMap(bodyParams);
   } else {
     byte res[] = null;
     try {
       res = URLUtils.doFormDataEncode(bodyParams, files, boundary).toByteArray();
     } catch (IOException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
     return res;
   }
   try {
     return body.getBytes(getCharset());
   } catch (UnsupportedEncodingException uee) {
     throw new OAuthException("Unsupported Charset: " + getCharset(), uee);
   }
 }
Exemple #2
0
  private void createConnection() throws IOException {
    String effectiveUrl = URLUtils.appendParametersToQueryString(url, querystringParams);
    if (connection == null) {
      System.setProperty("http.keepAlive", connectionKeepAlive ? "true" : "false");
      // connection = (HttpURLConnection) new URL(effectiveUrl).openConnection();

      URL url = new URL(effectiveUrl);
      if (url.getProtocol().toLowerCase().equals("https")) {
        trustAllHosts();
        HttpsURLConnection https = (HttpsURLConnection) url.openConnection();
        https.setHostnameVerifier(DO_NOT_VERIFY);
        connection = https;
      } else {
        connection = (HttpURLConnection) url.openConnection();
      }
    }
  }