code: private void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {
          if (this.connectTimeout >= 0) {
              connection.setConnectTimeout(this.connectTimeout);
          }
          if (this.readTimeout >= 0) {
              connection.setReadTimeout(this.readTimeout);
          }
  
          connection.setDoInput(true);
  
          if ("GET".equals(httpMethod)) {
              connection.setInstanceFollowRedirects(true);
          } else {
              connection.setInstanceFollowRedirects(false);
          }
  
          if ("POST".equals(httpMethod) || "PUT".equals(httpMethod) || "PATCH".equals(httpMethod) || "DELETE".equals(httpMethod)) {
              connection.setDoOutput(true);
          } else {
              connection.setDoOutput(false);
          }
  
          connection.setRequestMethod(httpMethod);
      }
docs: Template method for preparing the given {@link HttpURLConnection}.
  <p>The default implementation prepares the connection for input and output, and sets the HTTP method.
  
  @param connection the connection to prepare
  @param httpMethod the HTTP request method ({@code GET}, {@code POST}, etc.)
  @throws IOException in case of I/O errors