Created
June 9, 2020 03:49
-
-
Save hrj/0d4f94dc9b2091dca1fb1358728a6d56 to your computer and use it in GitHub Desktop.
Simple script to check java http client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.http.* | |
var targetPath = "https://duckduckgo.com/html" | |
var r = HttpRequest.newBuilder().uri(URI.create(targetPath)).build() | |
var hc = HttpClient.newHttpClient() | |
System.out.println("Sending request: " + r) | |
var resp = hc.send(r, HttpResponse.BodyHandlers.discarding()) | |
System.out.println("response code is: " + resp.statusCode()) | |
/exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment