java.lang.Object
com.hedera.hashgraph.sdk.HttpRequest
One request handed to an
HttpTransport.
Note that this is the SDK's own transport-layer type, not java.net.http.HttpRequest. A
single-type import of the JDK type still wins inside a compilation unit that asks for it, so
existing code is unaffected.
The url is absolute and already resolved — a transport never joins anything. Header names
are lowercase, and the map is never null; an empty map is the absence of headers.
-
Method Summary
Modifier and TypeMethodDescriptionstatic HttpRequestcreate(HttpMethod method, String url) Create a bodyless request.byte @Nullable []getBody()Extract a copy of the request body.@Nullable StringExtract the body's media type.@Nullable DurationExtract the bound on the whole exchange.Extract the request headers, with lowercased names.Extract the HTTP method.getUrl()Extract the absolute URL.toString()Derive a copy carrying a body.withDeadline(@Nullable Duration deadline) Derive a copy bounded by a deadline.withHeader(String name, String value) Derive a copy carrying one more header.withHeaders(Map<String, String> headers) Derive a copy whose headers are replaced wholesale.
-
Method Details
-
create
Create a bodyless request.- Parameters:
method- the HTTP methodurl- an absolutehttporhttpsURL- Returns:
- the new request
-
withBody
Derive a copy carrying a body.- Parameters:
body- the request body; defensively copiedcontentType- the body's media type- Returns:
- the derived request
-
withHeader
Derive a copy carrying one more header. The name is lowercased.- Parameters:
name- the header namevalue- the header value- Returns:
- the derived request
-
withHeaders
Derive a copy whose headers are replaced wholesale. Names are lowercased.- Parameters:
headers- the headers to carry- Returns:
- the derived request
-
withDeadline
Derive a copy bounded by a deadline.The deadline bounds the whole exchange, body included — not time to first byte. A transport must abandon the exchange and fail with
HttpTransportErrorKind.TIMEOUT_ERRORwhen it elapses.- Parameters:
deadline- the bound, or null for no bound of the caller's own- Returns:
- the derived request
-
getMethod
Extract the HTTP method.- Returns:
- the method
-
getUrl
Extract the absolute URL.- Returns:
- the URL
-
getBody
public byte @Nullable [] getBody()Extract a copy of the request body.- Returns:
- the body, or null on a bodyless method
-
getContentType
Extract the body's media type.- Returns:
- the content type, or null on a bodyless method
-
getHeaders
Extract the request headers, with lowercased names.- Returns:
- an unmodifiable map, never null
-
getDeadline
Extract the bound on the whole exchange.- Returns:
- the deadline, or null when the caller imposes no bound of its own
-
toString
-