@ -26,6 +26,7 @@ import java.nio.charset.Charset;
@@ -26,6 +26,7 @@ import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets ;
import java.security.Principal ;
import java.text.SimpleDateFormat ;
import java.time.ZonedDateTime ;
import java.util.ArrayList ;
import java.util.Arrays ;
import java.util.Collection ;
@ -35,6 +36,7 @@ import java.util.List;
@@ -35,6 +36,7 @@ import java.util.List;
import java.util.Locale ;
import java.util.Map ;
import java.util.TimeZone ;
import java.util.function.Consumer ;
import jakarta.servlet.ServletContext ;
import jakarta.servlet.ServletRequest ;
@ -348,6 +350,37 @@ public abstract class AbstractMockHttpServletRequestBuilder<B extends AbstractMo
@@ -348,6 +350,37 @@ public abstract class AbstractMockHttpServletRequestBuilder<B extends AbstractMo
return self ( ) ;
}
/ * *
* Set the list of acceptable { @linkplain Charset charsets } , as specified
* by the { @code Accept - Charset } header .
* @param acceptableCharsets the acceptable charsets
* @since 7 . 0
* /
public B acceptCharset ( Charset . . . acceptableCharsets ) {
this . headers . setAcceptCharset ( Arrays . asList ( acceptableCharsets ) ) ;
return self ( ) ;
}
/ * *
* Set the value of the { @code If - Modified - Since } header .
* @param ifModifiedSince the new value of the header
* @since 7 . 0
* /
public B ifModifiedSince ( ZonedDateTime ifModifiedSince ) {
this . headers . setIfModifiedSince ( ifModifiedSince ) ;
return self ( ) ;
}
/ * *
* Set the values of the { @code If - None - Match } header .
* @param ifNoneMatches the new value of the header
* @since 7 . 0
* /
public B ifNoneMatch ( String . . . ifNoneMatches ) {
this . headers . setIfNoneMatch ( Arrays . asList ( ifNoneMatches ) ) ;
return self ( ) ;
}
/ * *
* Add a header to the request . Values are always added .
* @param name the header name
@ -386,6 +419,18 @@ public abstract class AbstractMockHttpServletRequestBuilder<B extends AbstractMo
@@ -386,6 +419,18 @@ public abstract class AbstractMockHttpServletRequestBuilder<B extends AbstractMo
return self ( ) ;
}
/ * *
* Provides access to every header declared so far with the possibility
* to add , replace , or remove values .
* @param headersConsumer the consumer to provide access to
* @return this builder
* @since 7 . 0
* /
public B headers ( Consumer < HttpHeaders > headersConsumer ) {
headersConsumer . accept ( this . headers ) ;
return self ( ) ;
}
/ * *
* Add a request parameter to { @link MockHttpServletRequest # getParameterMap ( ) } .
* < p > In the Servlet API , a request parameter may be parsed from the query