java.lang.Object
org.miaixz.bus.http.Request
An HTTP request, encapsulating all information for a single request, including the URL, method, headers, body, and
tags.
Note: Instances of this class are immutable if the body is null or also immutable. The request body can,
however, affect the state of the instance.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA builder for creating and modifyingRequestinstances. -
Method Summary
Modifier and TypeMethodDescriptionbody()Returns the request body.Returns the cache control directives for this request.Returns the first header value for the given name.headers()Returns all headers for this request.Returns a list of header values for the given name.booleanisHttps()Returns true if this request uses the HTTPS protocol.method()Returns the HTTP method for this request.Creates a new builder instance initialized with this request's properties.tag()Returns the tag attached to this request withObject.classas the key.<T> TReturns the tag of the specified type attached to this request.toString()Returns a string representation of this request.url()Returns the URL for this request.
-
Method Details
-
url
Returns the URL for this request.- Returns:
- The
UnoUrlobject.
-
method
Returns the HTTP method for this request.- Returns:
- The method name (e.g., GET, POST).
-
headers
Returns all headers for this request.- Returns:
- The
Headersobject.
-
header
Returns the first header value for the given name.- Parameters:
name- The header name.- Returns:
- The header value, or null if not found.
-
headers
Returns a list of header values for the given name.- Parameters:
name- The header name.- Returns:
- A list of header values, which may be empty.
-
body
Returns the request body.- Returns:
- The
RequestBodyobject, which may be null.
-
tag
Returns the tag attached to this request withObject.classas the key.If no tag is attached, this returns null. To get a tag from a derived request, a new instance must be created with
newBuilder().- Returns:
- The tag object, which may be null.
-
tag
Returns the tag of the specified type attached to this request.This uses the specified
typeas a key to look up a value from the tags map. The returned value will be an instance of the specified type, or null if no tag is found.- Type Parameters:
T- The type of the tag value.- Parameters:
type- The type of the tag.- Returns:
- The tag value, which may be null.
-
newBuilder
Creates a new builder instance initialized with this request's properties.- Returns:
- A new
Request.Builderinstance.
-
cacheControl
Returns the cache control directives for this request.This returns a non-null
CacheControlobject even if this request does not have a "Cache-Control" header. Lazily initialized for performance.- Returns:
- The
CacheControlobject.
-
isHttps
public boolean isHttps()Returns true if this request uses the HTTPS protocol.- Returns:
trueif the URL uses HTTPS.
-
toString
Returns a string representation of this request.
-