Class HttpRequest
- java.lang.Object
-
- com.github.nosan.embedded.cassandra.commons.web.HttpRequest
-
public class HttpRequest extends Object
Represents an HTTP request message.This class encapsulates the important components of an HTTP request, including the URI, HTTP method, and headers, to provide a structured way to create and use HTTP requests.
By default, if not specified, the HTTP method is set to
GETand no headers are included.The
HttpHeadersobject is used to manage request headers, supporting case-insensitive header names and convenient methods for adding or retrieving header values.- Since:
- 4.0.0
- Author:
- Dmytro Nosan
-
-
Constructor Summary
Constructors Constructor Description HttpRequest(URI uri)Creates a newHttpRequestwith the specified URI and the default HTTPGETmethod.HttpRequest(URI uri, String method)Creates a newHttpRequestwith the specified URI and HTTP method.HttpRequest(URI uri, String method, HttpHeaders headers)Creates a newHttpRequestwith the specified URI, HTTP method, and headers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpHeadersgetHeaders()Returns the HTTP headers associated with this request.StringgetMethod()Returns the HTTP method of the request.URIgetUri()Returns the URI of the request.StringtoString()Returns a string representation of the HTTP request.
-
-
-
Constructor Detail
-
HttpRequest
public HttpRequest(URI uri)
Creates a newHttpRequestwith the specified URI and the default HTTPGETmethod.- Parameters:
uri- the URI of the request- Throws:
NullPointerException- ifuriisnull
-
HttpRequest
public HttpRequest(URI uri, String method)
Creates a newHttpRequestwith the specified URI and HTTP method.- Parameters:
uri- the URI of the requestmethod- the HTTP method of the request (e.g.,GET,POST)- Throws:
NullPointerException- ifuriormethodisnull
-
HttpRequest
public HttpRequest(URI uri, String method, HttpHeaders headers)
Creates a newHttpRequestwith the specified URI, HTTP method, and headers.- Parameters:
uri- the URI of the requestmethod- the HTTP method of the request (e.g.,GET,POST)headers- the HTTP headers of the request- Throws:
NullPointerException- ifuri,method, orheadersisnull
-
-
Method Detail
-
getUri
public URI getUri()
Returns the URI of the request.- Returns:
- the URI of the request
-
getMethod
public String getMethod()
Returns the HTTP method of the request.The method is always returned in uppercase to ensure compatibility with standard HTTP conventions.
- Returns:
- the HTTP method of the request
-
getHeaders
public HttpHeaders getHeaders()
Returns the HTTP headers associated with this request.The headers are represented as a
HttpHeadersobject, allowing for easy access and modification of individual headers.- Returns:
- the HTTP headers of the request
-
-