Interface SlingHttpServletRequestBuilder
@ProviderType
public interface SlingHttpServletRequestBuilder
Fluent helper for building a request.
Note: instances of this interface are not thread-safe.
- Since:
- 1.0 (Sling API Bundle 2.24.0)
-
Method Summary
Modifier and TypeMethodDescription@NotNull SlingHttpServletRequest
build()
Builds the request.@NotNull SlingHttpServletRequestBuilder
useAttributesFrom
(@NotNull javax.servlet.http.HttpServletRequest request) Uses the attributes backed by the provided request.@NotNull SlingHttpServletRequestBuilder
useRequestDispatcherFrom
(@NotNull SlingHttpServletRequest request) Uses the request dispatcher from the provided request.@NotNull SlingHttpServletRequestBuilder
useServletContextFrom
(@NotNull javax.servlet.http.HttpServletRequest request) Uses the servlet context from the provided request.@NotNull SlingHttpServletRequestBuilder
useSessionFrom
(@NotNull javax.servlet.http.HttpServletRequest request) Uses the session from the provided request.@NotNull SlingHttpServletRequestBuilder
Uses the supplied content as the request's body content.@NotNull SlingHttpServletRequestBuilder
withContentType
(@Nullable String contentType) Sets the HTTP request'sContent-Type
header.@NotNull SlingHttpServletRequestBuilder
withExtension
(@Nullable String extension) Sets the optional extension of the internal request, which influences the servlet/script resolution.@NotNull SlingHttpServletRequestBuilder
withParameter
(@NotNull String key, @NotNull String value) Sets a request parameter.@NotNull SlingHttpServletRequestBuilder
withParameter
(@NotNull String key, @NotNull String[] values) Sets a request parameter.@NotNull SlingHttpServletRequestBuilder
withParameters
(@Nullable Map<String, String[]> parameters) Adds the supplied request parameters to the current ones.@NotNull SlingHttpServletRequestBuilder
withRequestMethod
(@NotNull String method) Sets the HTTP request method to use - defaults toGET
.@NotNull SlingHttpServletRequestBuilder
withRequestProgressTracker
(@NotNull RequestProgressTracker tracker) Uses the provided request progress tracker@NotNull SlingHttpServletRequestBuilder
withSelectors
(@Nullable String... selectors) Sets the optional selectors of the internal request, which influence the servlet/script resolution.@NotNull SlingHttpServletRequestBuilder
withSuffix
(@Nullable String suffix) Sets the optional suffix of the internal request.
-
Method Details
-
withRequestMethod
Sets the HTTP request method to use - defaults toGET
.- Parameters:
method
- the HTTP method- Returns:
- this object
- Throws:
IllegalArgumentException
- If method isnull
-
withContentType
@NotNull @NotNull SlingHttpServletRequestBuilder withContentType(@Nullable @Nullable String contentType) Sets the HTTP request'sContent-Type
header.- Parameters:
contentType
- theContent-Type
value- Returns:
- this object
-
withBody
Uses the supplied content as the request's body content.- Parameters:
content
- the request body content- Returns:
- this object
-
withSelectors
@NotNull @NotNull SlingHttpServletRequestBuilder withSelectors(@Nullable @Nullable String... selectors) Sets the optional selectors of the internal request, which influence the servlet/script resolution.- Parameters:
selectors
- the selectors- Returns:
- this object
-
withExtension
@NotNull @NotNull SlingHttpServletRequestBuilder withExtension(@Nullable @Nullable String extension) Sets the optional extension of the internal request, which influences the servlet/script resolution.- Parameters:
extension
- the extension- Returns:
- this object
-
withSuffix
Sets the optional suffix of the internal request.- Parameters:
suffix
- the suffix- Returns:
- this object
-
withParameter
@NotNull @NotNull SlingHttpServletRequestBuilder withParameter(@NotNull @NotNull String key, @NotNull @NotNull String value) Sets a request parameter.- Parameters:
key
- the name of the parametervalue
- the value of the parameter- Returns:
- this object
- Throws:
IllegalArgumentException
- if eitherkey
orvalue
isnull
-
withParameter
@NotNull @NotNull SlingHttpServletRequestBuilder withParameter(@NotNull @NotNull String key, @NotNull @NotNull String[] values) Sets a request parameter.- Parameters:
key
- the name of the parametervalues
- the values of the parameter- Returns:
- this object
- Throws:
IllegalArgumentException
- if eitherkey
orvalues
isnull
-
withParameters
@NotNull @NotNull SlingHttpServletRequestBuilder withParameters(@Nullable @Nullable Map<String, String[]> parameters) Adds the supplied request parameters to the current ones.- Parameters:
parameters
- additional parameters- Returns:
- this object
-
useRequestDispatcherFrom
@NotNull @NotNull SlingHttpServletRequestBuilder useRequestDispatcherFrom(@NotNull @NotNull SlingHttpServletRequest request) Uses the request dispatcher from the provided request.- Parameters:
request
- the request from which to use the dispatcher- Returns:
- this object
- Throws:
IllegalArgumentException
- ifrequest
isnull
-
useSessionFrom
@NotNull @NotNull SlingHttpServletRequestBuilder useSessionFrom(@NotNull @NotNull javax.servlet.http.HttpServletRequest request) Uses the session from the provided request.- Parameters:
request
- the request from which to use the session- Returns:
- this object
- Throws:
IllegalArgumentException
- ifrequest
isnull
-
useAttributesFrom
@NotNull @NotNull SlingHttpServletRequestBuilder useAttributesFrom(@NotNull @NotNull javax.servlet.http.HttpServletRequest request) Uses the attributes backed by the provided request.- Parameters:
request
- the request from which to use the attributes- Returns:
- this object
- Throws:
IllegalArgumentException
- ifrequest
isnull
-
useServletContextFrom
@NotNull @NotNull SlingHttpServletRequestBuilder useServletContextFrom(@NotNull @NotNull javax.servlet.http.HttpServletRequest request) Uses the servlet context from the provided request.- Parameters:
request
- the request from which to use the servlet context- Returns:
- this object
- Throws:
IllegalArgumentException
- ifrequest
isnull
-
withRequestProgressTracker
@NotNull @NotNull SlingHttpServletRequestBuilder withRequestProgressTracker(@NotNull @NotNull RequestProgressTracker tracker) Uses the provided request progress tracker- Parameters:
tracker
- The tracker- Returns:
- this object
- Since:
- 1.1 (Sling API Bundle 2.25.0)
-
build
Builds the request. Once this method has been called, the builder must not be used anymore. In order to create a new request a new builder has to be used.- Returns:
- a request object
-