HttpClient httpClient = new HttpClient(); GetMethod method = new GetMethod("http://example.com/api/endpoint"); int statusCode = httpClient.executeMethod(method); String responseBody = method.getResponseBodyAsString(); if (statusCode == HttpStatus.SC_OK) { System.out.println("Response: " + responseBody); } else { System.out.println("Error: " + statusCode); } httpClient.getParams().setParameter("http.protocol.expect-continue", false); httpClient.getParams().setParameter("http.protocol.allow-circular-redirects", true); httpClient.getParams().setParameter("http.protocol.handle-redirects", false); Protocol.registerProtocol("https", new Protocol("https", new TrustAllSSLSocketFactory(), 443));


上一篇:
下一篇:
切换中文