Class InternalRequest
java.lang.Object
org.apache.sling.servlethelpers.internalrequests.BaseInternalRequest
org.apache.sling.servlethelpers.internalrequests.InternalRequest
- Direct Known Subclasses:
ServletInternalRequest,SlingInternalRequest
Deprecated.
Fluent helper for Sling internal requests.
The
ServletInternalRequest and SlingInternalRequest
subclasses provide two modes for executing the
internal requests, one that's very similar to the way Sling
executes an HTTP request and another one that's faster by
calling Servlets or Scripts directly.-
Field Summary
Fields inherited from class org.apache.sling.servlethelpers.internalrequests.BaseInternalRequest
bodyReader, contentType, DEFAULT_METHOD, explicitStatusCheck, extension, log, MDC_KEY, parameters, path, requestMethod, resourceResolver, selectorString -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInternalRequest(@NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @NotNull String path) Deprecated.Clients use subclasses of this one -
Method Summary
Modifier and TypeMethodDescriptionprotected voidDeprecated.checkResponseContentType(String contentType) Deprecated.After executing the request, checks that the response content-type is as expected.checkStatus(int... acceptableValues) Deprecated.After executing the request, checks that the request status is one of the supplied values.protected abstract voiddelegateExecute(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response, org.apache.sling.api.resource.ResourceResolver resourceResolver) Deprecated.Execute the supplied Requestfinal InternalRequestexecute()Deprecated.Execute the internal request.org.apache.sling.api.SlingHttpServletResponseDeprecated.Return the response object.Deprecated.Return the response as a String.intDeprecated.Return the response status.Deprecated.Use the supplied Reader as the request's body contentwithContentType(String contentType) Deprecated.Set the HTTP request's Content-TypewithExtension(String extension) Deprecated.Sets the optional extension of the internal request, which influence the Servlet/Script resolution.withParameter(String key, Object value) Deprecated.Set a request parameterwithParameters(Map<String, Object> additionalParameters) Deprecated.Add the supplied request parameters to the current oneswithRequestMethod(String method) Deprecated.Set the HTTP request method to use - defaults to GETwithSelectors(String... selectors) Deprecated.Sets the optional selectors of the internal request, which influence the Servlet/Script resolution.Methods inherited from class org.apache.sling.servlethelpers.internalrequests.BaseInternalRequest
checkNotNull, checkNotNull, getExecutionResource
-
Constructor Details
-
InternalRequest
protected InternalRequest(@NotNull @NotNull org.apache.sling.api.resource.ResourceResolver resourceResolver, @NotNull @NotNull String path) Deprecated.Clients use subclasses of this one
-
-
Method Details
-
withRequestMethod
Deprecated.Description copied from class:BaseInternalRequestSet the HTTP request method to use - defaults to GET- Overrides:
withRequestMethodin classBaseInternalRequest
-
withContentType
Deprecated.Description copied from class:BaseInternalRequestSet the HTTP request's Content-Type- Overrides:
withContentTypein classBaseInternalRequest
-
withBody
Deprecated.Description copied from class:BaseInternalRequestUse the supplied Reader as the request's body content- Overrides:
withBodyin classBaseInternalRequest
-
withSelectors
Deprecated.Description copied from class:BaseInternalRequestSets the optional selectors of the internal request, which influence the Servlet/Script resolution.- Overrides:
withSelectorsin classBaseInternalRequest
-
withExtension
Deprecated.Description copied from class:BaseInternalRequestSets the optional extension of the internal request, which influence the Servlet/Script resolution.- Overrides:
withExtensionin classBaseInternalRequest
-
withParameter
Deprecated.Description copied from class:BaseInternalRequestSet a request parameter- Overrides:
withParameterin classBaseInternalRequest
-
withParameters
Deprecated.Description copied from class:BaseInternalRequestAdd the supplied request parameters to the current ones- Overrides:
withParametersin classBaseInternalRequest
-
execute
Deprecated.Execute the internal request. Can be called right after creating it, if no options need to be set.- Specified by:
executein classBaseInternalRequest- Throws:
IOException- if the request was already executed, or if an error occurs during execution.
-
delegateExecute
protected abstract void delegateExecute(org.apache.sling.api.SlingHttpServletRequest request, org.apache.sling.api.SlingHttpServletResponse response, org.apache.sling.api.resource.ResourceResolver resourceResolver) throws javax.servlet.ServletException, IOException Deprecated.Execute the supplied Request- Throws:
javax.servlet.ServletExceptionIOException
-
assertRequestExecuted
Deprecated.- Specified by:
assertRequestExecutedin classBaseInternalRequest- Throws:
IOException
-
checkStatus
Deprecated.Description copied from class:BaseInternalRequestAfter executing the request, checks that the request status is one of the supplied values. If this is not called before methods that access the response, a check for a 200 OK status is done automatically unless this was called with no arguments before. This makes sure a status check is done or explicitly disabled.- Overrides:
checkStatusin classBaseInternalRequest- Parameters:
acceptableValues- providing no values means "don't care"- Throws:
IOException- if status doesn't match any of these values
-
checkResponseContentType
Deprecated.After executing the request, checks that the response content-type is as expected.- Specified by:
checkResponseContentTypein classBaseInternalRequest- Throws:
IOException- if the actual content-type doesn't match the expected one
-
getStatus
Deprecated.Return the response status. The execute method must be called before this one.- Specified by:
getStatusin classBaseInternalRequest- Throws:
IOException- if the request hasn't been executed yet
-
getResponse
Deprecated.Return the response object. The execute method must be called before this one. A check for "200 OK" status is done automatically unlesscheckStatus(int...)has been called before.- Throws:
IOException- if the request hasn't been executed yet or if the status check fails.
-
getResponseAsString
Deprecated.Return the response as a String. The execute method must be called before this one. A check for "200 OK" status is done automatically unlesscheckStatus(int...)has been called before.- Specified by:
getResponseAsStringin classBaseInternalRequest- Throws:
IOException- if the request hasn't been executed yet or if the status check fails.
-
JakartaInternalRequestinstead.