import org.littleshoot.proxy.impl.DefaultHttpProxyServer; import org.littleshoot.proxy.HttpProxyServer; public class HttpClientExample { public static void main(String[] args) { HttpProxyServer proxyServer = DefaultHttpProxyServer.bootstrap() .withPort(8080) .start(); Wrapper httpClient = new Wrapper(); String url = "https://api.example.com/data"; WrapperResponse response = httpClient.get(url); int statusCode = response.getStatusCode(); String responseBody = response.getBody(); System.out.println("Status code: " + statusCode); System.out.println("Response body: " + responseBody); proxyServer.stop(); } } Wrapper httpClient = new Wrapper(); httpClient.addHeader("Authorization", "Bearer token"); Wrapper httpClient = new Wrapper(); httpClient.setTimeout(5000); Wrapper httpClient = new Wrapper(); httpClient.setProxy("localhost", 8080);


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