Package dev.gmitch215.bytebox.net.http
Class HttpRequest
java.lang.Object
dev.gmitch215.bytebox.net.http.HttpRequest
A request, standing in for
java.net.http.HttpRequest.
Built the same way as anywhere else, and sent by HttpClient.
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://example.com/things"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString("{}"))
.build();
- Since:
- 1.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA request body.static final classThe request bodies there are.static final classAssembles a request. -
Method Summary
Modifier and TypeMethodDescriptionReturns the body, empty for a request that carries none.headers()Returns the headers.method()Returns the method.static HttpRequest.BuilderReturns a builder.static HttpRequest.BuildernewBuilder(URI uri) A builder aimed at a URI.timeout()Returns how long the request may take, empty for no limit.toString()uri()Returns where the request goes.
-
Method Details
-
newBuilder
Returns a builder.- Returns:
- a builder
-
newBuilder
A builder aimed at a URI.- Parameters:
uri- where to send it- Returns:
- the builder
-
uri
Returns where the request goes.- Returns:
- where the request goes
-
method
Returns the method.- Returns:
- the method
-
headers
Returns the headers.- Returns:
- the headers
-
bodyPublisher
Returns the body, empty for a request that carries none.- Returns:
- the body, empty for a request that carries none
-
timeout
Returns how long the request may take, empty for no limit.- Returns:
- how long the request may take, empty for no limit
-
toString
-