Return content-type from saved request
This commit is contained in:
parent
30d016bcbd
commit
07f737b989
|
@ -32,6 +32,7 @@ import jakarta.servlet.http.HttpServletRequest;
|
|||
import jakarta.servlet.http.HttpServletRequestWrapper;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
/**
|
||||
* Provides request parameters, headers and cookies from either an original request or a
|
||||
|
@ -141,6 +142,11 @@ class SavedRequestAwareWrapper extends HttpServletRequestWrapper {
|
|||
return this.savedRequest.getMethod();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContentType() {
|
||||
return getHeader(HttpHeaders.CONTENT_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the parameter is available from the wrapped request then the request has been
|
||||
* forwarded/included to a URL with parameters, either supplementing or overriding the
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.Locale;
|
|||
import jakarta.servlet.http.Cookie;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.security.web.PortResolverImpl;
|
||||
|
||||
|
@ -169,4 +170,13 @@ public class SavedRequestAwareWrapperTests {
|
|||
assertThat(wrapper.getIntHeader("nonexistent")).isEqualTo(-1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void correctContentTypeIsReturned() {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest("PUT", "/notused");
|
||||
request.setContentType(MediaType.APPLICATION_FORM_URLENCODED_VALUE);
|
||||
|
||||
SavedRequestAwareWrapper wrapper = createWrapper(request, new MockHttpServletRequest("GET", "/notused"));
|
||||
assertThat(wrapper.getContentType()).isEqualTo(MediaType.APPLICATION_FORM_URLENCODED_VALUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue