Package com.storedobject.common
Class HTTP2
java.lang.Object
com.storedobject.common.HTTP2
The HTTP2 class facilitates HTTP/2 client-server communication
with helper methods and a builder pattern for request customization.
It leverages Java's HttpClient for synchronous and asynchronous
HTTP calls and provides utilities for handling and parsing responses.
Note: This utility class can transparently handle chunked and compressed (zipped or deflated) content as well.
Typical usage:
String s = HTTP2.build("https://www.google.com").string();
System.out.println("Google's default page's content is: " + s);
JSON json = HTT2.build("https://www.example.com?api=xxx").json(); // Get the JSON content
- Author:
- Syam
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis class provides a builder pattern for constructing HTTP requests. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic HTTP2.Builderbuilder()Creates a new instance of theBuilderclass, which provides methods to configure and build an HTTP request.static HTTP2.BuilderCreates a newBuilderinstance initialized with the specified URL.
-
Constructor Details
-
HTTP2
public HTTP2()
-
-
Method Details
-
builder
Creates a new instance of theBuilderclass, which provides methods to configure and build an HTTP request.- Returns:
- a new
Builderinstance
-
builder
Creates a newBuilderinstance initialized with the specified URL.- Parameters:
url- the URL to be set for the builder- Returns:
- a new
Builderinstance with the URL set
-