code:     public static int methodUrl(String path, ByteChunk out, int readTimeout,
              Map<String, List<String>> reqHead,
              Map<String, List<String>> resHead,
              String method) throws IOException {
  
          URL url = new URL(path);
          HttpURLConnection connection =
              (HttpURLConnection) url.openConnection();
          connection.setUseCaches(false);
          connection.setReadTimeout(readTimeout);
          connection.setRequestMethod(method);
          if (reqHead != null) {
              for (Map.Entry<String, List<String>> entry : reqHead.entrySet()) {
                  StringBuilder valueList = new StringBuilder();
                  for (String value : entry.getValue()) {
                      if (valueList.length() > 0) {
                          valueList.append(',');
                      }
                      valueList.append(value);
                  }
                  connection.setRequestProperty(entry.getKey(),
                          valueList.toString());
              }
          }
          connection.connect();
          int rc = connection.getResponseCode();
          if (resHead != null) {
              Map<String, List<String>> head = connection.getHeaderFields();
              resHead.putAll(head);
          }
          InputStream is;
          if (rc < 400) {
              is = connection.getInputStream();
          } else {
              is = connection.getErrorStream();
          }
          if (is != null) {
              try (BufferedInputStream bis = new BufferedInputStream(is)) {
                  byte[] buf = new byte[2048];
                  int rd = 0;
                  while((rd = bis.read(buf)) > 0) {
                      out.append(buf, 0, rd);
                  }
              }
          }
          return rc;
      }
  
  