content: package com.aixcode.autoTest.generate.copilot;
  
  import com.aixcode.autoTest.GenerateMethodBase;
  
  import java.net.HttpURLConnection;
  import java.net.URL;
  import java.util.Map;
  
  public class GenerateMethod2 extends GenerateMethodBase {
      /**
       * Create and returns a HttpURLConnection connection to a webpage
       */
      public HttpURLConnection createHttpConnection(URL url, int connectTimeout, Map<String, String> requestProperties) throws Exception {
          HttpURLConnection connection = (HttpURLConnection) url.openConnection();
          connection.setConnectTimeout(connectTimeout);
          connection.setReadTimeout(connectTimeout);
          connection.setRequestMethod("GET");
          connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11");
          connection.setRequestProperty("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
          connection.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
          connection.setRequestProperty("Accept-Encoding", "gzip, deflate");
          connection.setRequestProperty("Connection", "keep-alive");
          connection.setRequestProperty("Cache-Control", "max-age=0");
          if (requestProperties != null) {
              for (Map.Entry<String, String> entry : requestProperties.entrySet()) {
                  connection.setRequestProperty(entry.getKey(), entry.getValue());
              }
          }
          return connection;
      }
  
  }
  