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 Details

    • withRequestMethod

      @NotNull @NotNull SlingHttpServletRequestBuilder withRequestMethod(@NotNull @NotNull String method)
      Sets the HTTP request method to use - defaults to GET.
      Parameters:
      method - the HTTP method
      Returns:
      this object
      Throws:
      IllegalArgumentException - If method is null
    • withContentType

      @NotNull @NotNull SlingHttpServletRequestBuilder withContentType(@Nullable @Nullable String contentType)
      Sets the HTTP request's Content-Type header.
      Parameters:
      contentType - the Content-Type value
      Returns:
      this object
    • withBody

      @NotNull @NotNull SlingHttpServletRequestBuilder withBody(@Nullable @Nullable 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 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

      @NotNull @NotNull SlingHttpServletRequestBuilder withSuffix(@Nullable @Nullable String suffix)
      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 parameter
      value - the value of the parameter
      Returns:
      this object
      Throws:
      IllegalArgumentException - if either key or value is null
    • withParameter

      @NotNull @NotNull SlingHttpServletRequestBuilder withParameter(@NotNull @NotNull String key, @NotNull @NotNull String[] values)
      Sets a request parameter.
      Parameters:
      key - the name of the parameter
      values - the values of the parameter
      Returns:
      this object
      Throws:
      IllegalArgumentException - if either key or values is null
    • 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 - if request is null
    • 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 - if request is null
    • 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 - if request is null
    • 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 - if request is null
    • 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