#HTTPCLIENT5 SSL error

1 messages · Page 1 of 1 (latest)

opal torrent
#
    public static void main(String[] args) {
        new Headers().foo();
        
    }

    public void foo() {
        try (CloseableHttpClient client = HttpClients.createDefault()) {
            HttpGet get = new HttpGet("https://www.scrapethissite.com/pages/advanced/?gotcha=headers");
            get.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
            get.setHeader("Accept-Encoding", "gzip, deflate, br, zstd");
            get.setHeader("Host", "www.scrapethissite.com");
            get.setHeader("Referer", "https://www.scrapethissite.com/pages/advanced/");
            get.setHeader("User-Agent", "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:144.0) Gecko/20100101 Firefox/144.0");
            try (ClassicHttpResponse resp = client.executeOpen(null, get, null)) {
                
                int responseCode = resp.getCode();
                System.out.println(responseCode);
                if (responseCode == 200) {
                    System.out.println(EntityUtils.toString(resp.getEntity(), "UTF-8"));
                }
            }
        } catch (IOException ex) {
            ex.printStackTrace();
        } catch (ParseException ex) {
            ex.printStackTrace();
        }
    }

I'm trying to fetch data from https website. When connecting, I get 200 response code, so the connection was succesfull. The thing is that I can't really decode the response.
These are the errors:

"java.security.NoSuchAlgorithmException: XDH AlgorithmParameters not available"
"java.io.EOFException: SSL peer shut down incorrectly"
"javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake"
"java.io.IOException: Stream interrupted" (this one many times)
vital cliffBOT
# opal torrent ```java public static void main(String[] args) { new Headers().foo()...

Detected code, here are some useful tools:

Formatted code
public static void main(String[] args) {
  new Headers().foo();
}
public void foo() {
  try (CloseableHttpClient client = HttpClients.createDefault()) {
    HttpGet get = new HttpGet("https://www.scrapethissite.com/pages/advanced/?gotcha=headers");
    get.setHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
    get.setHeader("Accept-Encoding", "gzip, deflate, br, zstd");
    get.setHeader("Host", "www.scrapethissite.com");
    get.setHeader("Referer", "https://www.scrapethissite.com/pages/advanced/");
    get.setHeader("User-Agent", "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:144.0) Gecko/20100101 Firefox/144.0");
    try (ClassicHttpResponse resp = client.executeOpen(null , get, null )) {
      int responseCode = resp.getCode();
      System.out.println(responseCode);
      if (responseCode == 200) {
        System.out.println(EntityUtils.toString(resp.getEntity(), "UTF-8"));
      }
    }
  } catch (IOException ex) {
    ex.printStackTrace();
  } catch (ParseException ex) {
    ex.printStackTrace();
  }
}
#

<@&987246452180930620> please have a look, thanks.

vital cliffBOT
#

@opal torrent

Your question has been closed due to inactivity.

If it was not resolved yet, feel free to just post a message below
to reopen it, or create a new thread.

Note that usually the reason for nobody calling back is that your
question may have been not well asked and hence no one felt confident
enough answering.

When you reopen the thread, try to use your time to improve the quality
of the question by elaborating, providing details, context, all relevant code
snippets, any errors you are getting, concrete examples and perhaps also some
screenshots. Share your attempt, explain the expected results and compare
them to the current results.

Also try to make the information easily accessible by sharing code
or assignment descriptions directly on Discord, not behind a link or
PDF-file; provide some guidance for long code snippets and ensure
the code is well formatted and has syntax highlighting. Kindly read through
https://stackoverflow.com/help/how-to-ask for more.

With enough info, someone knows the answer for sure 👍