001/*
002 * Copyright 2002-2013 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.test.web.servlet.request;
018
019import org.springframework.mock.web.MockHttpServletRequest;
020
021/**
022 * Extension point for applications or 3rd party libraries that wish to further
023 * initialize a {@link MockHttpServletRequest} instance after it has been built
024 * by {@link MockHttpServletRequestBuilder} or its subclass
025 * {@link MockMultipartHttpServletRequestBuilder}.
026 *
027 * <p>Implementations of this interface can be provided to
028 * {@link MockHttpServletRequestBuilder#with(RequestPostProcessor)} at the time
029 * when a request is about to be constructed.
030 *
031 * @author Rossen Stoyanchev
032 * @author Rob Winch
033 * @since 3.2
034 */
035public interface RequestPostProcessor {
036
037        /**
038         * Post-process the given {@code MockHttpServletRequest} after its creation
039         * and initialization through a {@code MockHttpServletRequestBuilder}.
040         * @param request the request to initialize
041         * @return the request to use, either the one passed in or a wrapped one
042         */
043        MockHttpServletRequest postProcessRequest(MockHttpServletRequest request);
044
045}