This seems quite verbose, and I find the order that we have to do things is confusing (why do we set headers after opening the URL?). Here’s how you would use it to make a GET request to get the APOD data: Titanic was rocking the box office and inspiring a thousand memes, Spice Girls had a best-selling album, but the biggest news of the year was surely HttpURLConnection being added to Java 1.1. Anyway, close your eyes and center yourself in 1997. Java 1.1 HttpURLConnectionįirst of all, do we capitalize acronyms in class names or not? Make your mind up. One of these might be a good choice if you are sensitive about adding extra dependencies to your project. Since Java 1.1 there has been an HTTP client in the core libraries provided with the JDK. Core Java APIs for making Java http requests I’ll use the Astronomy Picture of the Day API from the NASA APIs for the code samples, and the code is all on GitHub in a project based on Java 11. If you use other ones, that’s great! Let me know about it. This post will introduce you to the Java HTTP clients that I reach for. For Java programmers there are many ways to do it - core libraries in the JDK and third-party libraries. Making HTTP requests is a core feature of modern programming, and is often one of the first things you want to do when learning a new programming language.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |