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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description @NotNull SlingHttpServletRequest
build()
Builds the request.@NotNull SlingHttpServletRequestBuilder
useAttributesFrom(@NotNull 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 HttpServletRequest request)
Uses the servlet context from the provided request.@NotNull SlingHttpServletRequestBuilder
useSessionFrom(@NotNull HttpServletRequest request)
Uses the session from the provided request.@NotNull SlingHttpServletRequestBuilder
withBody(@Nullable java.lang.String content)
Uses the supplied content as the request's body content.@NotNull SlingHttpServletRequestBuilder
withContentType(@Nullable java.lang.String contentType)
Sets the HTTP request'sContent-Type
header.@NotNull SlingHttpServletRequestBuilder
withExtension(@Nullable java.lang.String extension)
Sets the optional extension of the internal request, which influences the servlet/script resolution.@NotNull SlingHttpServletRequestBuilder
withParameter(@NotNull java.lang.String key, @NotNull java.lang.String value)
Sets a request parameter.@NotNull SlingHttpServletRequestBuilder
withParameter(@NotNull java.lang.String key, @NotNull java.lang.String[] values)
Sets a request parameter.@NotNull SlingHttpServletRequestBuilder
withParameters(@Nullable java.util.Map<java.lang.String,java.lang.String[]> parameters)
Adds the supplied request parameters to the current ones.@NotNull SlingHttpServletRequestBuilder
withRequestMethod(@NotNull java.lang.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 java.lang.String... selectors)
Sets the optional selectors of the internal request, which influence the servlet/script resolution.@NotNull SlingHttpServletRequestBuilder
withSuffix(@Nullable java.lang.String suffix)
Sets the optional suffix of the internal request.
-
-
-
Method Detail
-
withRequestMethod
@NotNull @NotNull SlingHttpServletRequestBuilder withRequestMethod(@NotNull @NotNull java.lang.String method)
Sets the HTTP request method to use - defaults toGET
.- Parameters:
method
- the HTTP method- Returns:
- this object
- Throws:
java.lang.IllegalArgumentException
- If method isnull
-
withContentType
@NotNull @NotNull SlingHttpServletRequestBuilder withContentType(@Nullable @Nullable java.lang.String contentType)
Sets the HTTP request'sContent-Type
header.- Parameters:
contentType
- theContent-Type
value- Returns:
- this object
-
withBody
@NotNull @NotNull SlingHttpServletRequestBuilder withBody(@Nullable @Nullable java.lang.String content)
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 java.lang.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 java.lang.String extension)
Sets the optional extension of the internal request, which influences the servlet/script resolution.- Parameters:
extension
- the extension- Returns:
- this object
-
withSuffix
@NotNull @NotNull SlingHttpServletRequestBuilder withSuffix(@Nullable @Nullable java.lang.String suffix)
Sets the optional suffix of the internal request.- Parameters:
suffix
- the suffix- Returns:
- this object
-
withParameter
@NotNull @NotNull SlingHttpServletRequestBuilder withParameter(@NotNull @NotNull java.lang.String key, @NotNull @NotNull java.lang.String value)
Sets a request parameter.- Parameters:
key
- the name of the parametervalue
- the value of the parameter- Returns:
- this object
- Throws:
java.lang.IllegalArgumentException
- if eitherkey
orvalue
isnull
-
withParameter
@NotNull @NotNull SlingHttpServletRequestBuilder withParameter(@NotNull @NotNull java.lang.String key, @NotNull @NotNull java.lang.String[] values)
Sets a request parameter.- Parameters:
key
- the name of the parametervalues
- the values of the parameter- Returns:
- this object
- Throws:
java.lang.IllegalArgumentException
- if eitherkey
orvalues
isnull
-
withParameters
@NotNull @NotNull SlingHttpServletRequestBuilder withParameters(@Nullable @Nullable java.util.Map<java.lang.String,java.lang.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:
java.lang.IllegalArgumentException
- ifrequest
isnull
-
useSessionFrom
@NotNull @NotNull SlingHttpServletRequestBuilder useSessionFrom(@NotNull @NotNull HttpServletRequest request)
Uses the session from the provided request.- Parameters:
request
- the request from which to use the session- Returns:
- this object
- Throws:
java.lang.IllegalArgumentException
- ifrequest
isnull
-
useAttributesFrom
@NotNull @NotNull SlingHttpServletRequestBuilder useAttributesFrom(@NotNull @NotNull HttpServletRequest request)
Uses the attributes backed by the provided request.- Parameters:
request
- the request from which to use the attributes- Returns:
- this object
- Throws:
java.lang.IllegalArgumentException
- ifrequest
isnull
-
useServletContextFrom
@NotNull @NotNull SlingHttpServletRequestBuilder useServletContextFrom(@NotNull @NotNull 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:
java.lang.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
@NotNull @NotNull SlingHttpServletRequest 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
-
-