title: How to fix net/http: HTTP/1.x transport connection broken: malformed HTTP response
body: <p>Whenever I try to do a GET requests for google.com I get this error:</p>
  <p><code>Get &quot;https://www.google.com/&quot;: net/http: HTTP/1.x transport connection broken: malformed HTTP response</code></p>
  <p>I want to try to get the homepage for google and I don't know why this is happening. Someone please help. I am using golang's uTls
  Here is my code:</p>
  <pre><code>func tls_connection(URL string) *http.Response {
  
      //Creating a cookie jar
      cookieJar, _ := cookiejar.New(nil)
  
      // Creating the client wrapper
      client := &amp;http.Client{
          Jar: cookieJar,
          Transport: &amp;http.Transport{
              DialTLSContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
                  tcpConn, err := (&amp;net.Dialer{}).DialContext(ctx, network, addr)
                  if err != nil {
                      return nil, err
                  }
                  config := tls.Config{InsecureSkipVerify: true}
                  tlsConn := tls.UClient(tcpConn, &amp;config, tls.HelloChrome_Auto)
  
                  // Parsing the URL for SNI
                  u, _ := url.Parse(URL)
                  tlsConn.SetSNI(u.Host)
  
                  err = tlsConn.Handshake()
                  if err != nil {
                      return nil, fmt.Errorf(&quot;uTlsConn.Handshake() error: %w&quot;, err)
                  }
                  return tlsConn, nil
              },
          },
      }
  
      // Establishes a request
      req, err := http.NewRequest(&quot;GET&quot;, URL, nil)
      req.Header.Add(&quot;user-agent&quot;, &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36&quot;)
  
      // the client.do wraps the request
      resp, err := client.Do(req)
      if err != nil {
          fmt.Println(err)
      } else {
          fmt.Println(resp.StatusCode)
          body, _ := ioutil.ReadAll(resp.Body)
          fmt.Println(string(body))
      }
      return resp
  }
  </code></pre>