Пример #1
0
 public void addFile(String name, String file) throws IOException {
   if (boundary == null) {
     boundary =
         Long.toHexString(System.currentTimeMillis()); // Just generate some unique random value.
   }
   files.put(name, file);
 }
Пример #2
0
 private void createConnection() throws IOException
 {
   String completeUrl = getCompleteUrl();
   if (connection == null)
   {
     System.setProperty("http.keepAlive", connectionKeepAlive ? "true" : "false");
     connection = (HttpURLConnection) new URL(completeUrl).openConnection();
     connection.setInstanceFollowRedirects(followRedirects);
   }
 }
Пример #3
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();
      }
    }
  }