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 SlingHttpServletRequestbuild()Builds the request.@NotNull SlingHttpServletRequestBuilderuseAttributesFrom(@NotNull javax.servlet.http.HttpServletRequest request) Uses the attributes backed by the provided request.@NotNull SlingHttpServletRequestBuilderuseRequestDispatcherFrom(@NotNull SlingHttpServletRequest request) Uses the request dispatcher from the provided request.@NotNull SlingHttpServletRequestBuilderuseServletContextFrom(@NotNull javax.servlet.http.HttpServletRequest request) Uses the servlet context from the provided request.@NotNull SlingHttpServletRequestBuilderuseSessionFrom(@NotNull javax.servlet.http.HttpServletRequest request) Uses the session from the provided request.@NotNull SlingHttpServletRequestBuilderUses the supplied content as the request's body content.@NotNull SlingHttpServletRequestBuilderwithContentType(@Nullable String contentType) Sets the HTTP request'sContent-Typeheader.@NotNull SlingHttpServletRequestBuilderwithExtension(@Nullable String extension) Sets the optional extension of the internal request, which influences the servlet/script resolution.@NotNull SlingHttpServletRequestBuilderwithParameter(@NotNull String key, @NotNull String value) Sets a request parameter.@NotNull SlingHttpServletRequestBuilderwithParameter(@NotNull String key, @NotNull String[] values) Sets a request parameter.@NotNull SlingHttpServletRequestBuilderwithParameters(@Nullable Map<String, String[]> parameters) Adds the supplied request parameters to the current ones.@NotNull SlingHttpServletRequestBuilderwithRequestMethod(@NotNull String method) Sets the HTTP request method to use - defaults toGET.@NotNull SlingHttpServletRequestBuilderwithRequestProgressTracker(@NotNull RequestProgressTracker tracker) Uses the provided request progress tracker@NotNull SlingHttpServletRequestBuilderwithSelectors(@Nullable String... selectors) Sets the optional selectors of the internal request, which influence the servlet/script resolution.@NotNull SlingHttpServletRequestBuilderwithSuffix(@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-Typeheader.- Parameters:
contentType- theContent-Typevalue- 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 eitherkeyorvalueisnull
-
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 eitherkeyorvaluesisnull
-
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- ifrequestisnull
-
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- ifrequestisnull
-
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- ifrequestisnull
-
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- ifrequestisnull
-
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
-