parent
31c5644691
commit
ab9fea6b8d
|
|
@ -213,8 +213,9 @@ final class HtmlUnitRequestBuilder implements RequestBuilder, Mergeable {
|
||||||
|
|
||||||
private void authType(MockHttpServletRequest request) {
|
private void authType(MockHttpServletRequest request) {
|
||||||
String authorization = header("Authorization");
|
String authorization = header("Authorization");
|
||||||
if (authorization != null) {
|
String[] authSplit = StringUtils.split(authorization, ": ");
|
||||||
request.setAuthType(StringUtils.split(authorization, ": ")[0]);
|
if (authSplit != null) {
|
||||||
|
request.setAuthType(authSplit[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -434,20 +435,19 @@ final class HtmlUnitRequestBuilder implements RequestBuilder, Mergeable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object merge(Object parent) {
|
public Object merge(Object parent) {
|
||||||
if (parent == null) {
|
if (parent instanceof RequestBuilder) {
|
||||||
return this;
|
if (parent instanceof MockHttpServletRequestBuilder) {
|
||||||
|
MockHttpServletRequestBuilder copiedParent = MockMvcRequestBuilders.get("/");
|
||||||
|
copiedParent.merge(parent);
|
||||||
|
this.parentBuilder = copiedParent;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.parentBuilder = (RequestBuilder) parent;
|
||||||
|
}
|
||||||
|
if (parent instanceof SmartRequestBuilder) {
|
||||||
|
this.parentPostProcessor = (SmartRequestBuilder) parent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (parent instanceof MockHttpServletRequestBuilder) {
|
|
||||||
MockHttpServletRequestBuilder copiedParent = MockMvcRequestBuilders.get("/");
|
|
||||||
copiedParent.merge(parent);
|
|
||||||
this.parentBuilder = copiedParent;
|
|
||||||
} else if (parent instanceof RequestBuilder) {
|
|
||||||
this.parentBuilder = (RequestBuilder) parent;
|
|
||||||
}
|
|
||||||
if (parent instanceof SmartRequestBuilder) {
|
|
||||||
this.parentPostProcessor = (SmartRequestBuilder) parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,10 +32,10 @@ import org.springframework.transaction.support.TransactionSynchronizationManager
|
||||||
* an event to a {@link TransactionalEventListener} annotated method. Supports
|
* an event to a {@link TransactionalEventListener} annotated method. Supports
|
||||||
* the exact same features as any regular {@link EventListener} annotated method
|
* the exact same features as any regular {@link EventListener} annotated method
|
||||||
* but is aware of the transactional context of the event publisher.
|
* but is aware of the transactional context of the event publisher.
|
||||||
* <p>
|
*
|
||||||
* Processing of {@link TransactionalEventListener} is enabled automatically when
|
* <p>Processing of {@link TransactionalEventListener} is enabled automatically
|
||||||
* Spring's transaction management is enabled. For other cases, registering a
|
* when Spring's transaction management is enabled. For other cases, registering
|
||||||
* bean of type {@link TransactionalEventListenerFactory} is required.
|
* a bean of type {@link TransactionalEventListenerFactory} is required.
|
||||||
*
|
*
|
||||||
* @author Stephane Nicoll
|
* @author Stephane Nicoll
|
||||||
* @author Juergen Hoeller
|
* @author Juergen Hoeller
|
||||||
|
|
@ -69,8 +69,11 @@ class ApplicationListenerMethodTransactionalAdapter extends ApplicationListenerM
|
||||||
}
|
}
|
||||||
processEvent(event);
|
processEvent(event);
|
||||||
}
|
}
|
||||||
else if (logger.isDebugEnabled()) {
|
else {
|
||||||
logger.debug("No transaction is running - skipping " + event);
|
// No transactional event execution at all
|
||||||
|
if (logger.isDebugEnabled()) {
|
||||||
|
logger.debug("No transaction is active - skipping " + event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -808,13 +808,14 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the (new) value of the {@code Host} header.
|
* Set the (new) value of the {@code Host} header.
|
||||||
* <p>If the given {@linkplain InetSocketAddress#getPort() port} is {@code 0}, the host header
|
* <p>If the given {@linkplain InetSocketAddress#getPort() port} is {@code 0},
|
||||||
* will only contain the {@linkplain InetSocketAddress#getHostString() hostname}.
|
* the host header will only contain the
|
||||||
|
* {@linkplain InetSocketAddress#getHostString() hostname}.
|
||||||
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public void setHost(InetSocketAddress host) {
|
public void setHost(InetSocketAddress host) {
|
||||||
String value =
|
String value = (host.getPort() != 0 ?
|
||||||
host.getPort() != 0 ? String.format("%s:%d", host.getHostString(), host.getPort()) :
|
String.format("%s:%d", host.getHostString(), host.getPort()) : host.getHostString());
|
||||||
host.getHostString();
|
|
||||||
set(HOST, value);
|
set(HOST, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -822,6 +823,7 @@ public class HttpHeaders implements MultiValueMap<String, String>, Serializable
|
||||||
* Return the value of the required {@code Host} header.
|
* Return the value of the required {@code Host} header.
|
||||||
* <p>If the header value does not contain a port, the returned
|
* <p>If the header value does not contain a port, the returned
|
||||||
* {@linkplain InetSocketAddress#getPort() port} will be {@code 0}.
|
* {@linkplain InetSocketAddress#getPort() port} will be {@code 0}.
|
||||||
|
* @since 5.0
|
||||||
*/
|
*/
|
||||||
public InetSocketAddress getHost() {
|
public InetSocketAddress getHost() {
|
||||||
String value = getFirst(HOST);
|
String value = getFirst(HOST);
|
||||||
|
|
|
||||||
|
|
@ -56,8 +56,8 @@ public abstract class HttpRange {
|
||||||
public ResourceRegion toResourceRegion(Resource resource) {
|
public ResourceRegion toResourceRegion(Resource resource) {
|
||||||
// Don't try to determine contentLength on InputStreamResource - cannot be read afterwards...
|
// Don't try to determine contentLength on InputStreamResource - cannot be read afterwards...
|
||||||
// Note: custom InputStreamResource subclasses could provide a pre-calculated content length!
|
// Note: custom InputStreamResource subclasses could provide a pre-calculated content length!
|
||||||
Assert.isTrue(InputStreamResource.class != resource.getClass(),
|
Assert.isTrue(resource.getClass() != InputStreamResource.class,
|
||||||
"Can't convert an InputStreamResource to a ResourceRegion");
|
"Cannot convert an InputStreamResource to a ResourceRegion");
|
||||||
try {
|
try {
|
||||||
long contentLength = resource.contentLength();
|
long contentLength = resource.contentLength();
|
||||||
Assert.isTrue(contentLength > 0, "Resource content length should be > 0");
|
Assert.isTrue(contentLength > 0, "Resource content length should be > 0");
|
||||||
|
|
@ -163,12 +163,12 @@ public abstract class HttpRange {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert each {@code HttpRange} into a {@code ResourceRegion},
|
* Convert each {@code HttpRange} into a {@code ResourceRegion}, selecting the
|
||||||
* selecting the appropriate segment of the given {@code Resource}
|
* appropriate segment of the given {@code Resource} using HTTP Range information.
|
||||||
* using the HTTP Range information.
|
|
||||||
* @param ranges the list of ranges
|
* @param ranges the list of ranges
|
||||||
* @param resource the resource to select the regions from
|
* @param resource the resource to select the regions from
|
||||||
* @return the list of regions for the given resource
|
* @return the list of regions for the given resource
|
||||||
|
* @since 4.3
|
||||||
*/
|
*/
|
||||||
public static List<ResourceRegion> toResourceRegions(List<HttpRange> ranges, Resource resource) {
|
public static List<ResourceRegion> toResourceRegions(List<HttpRange> ranges, Resource resource) {
|
||||||
if (CollectionUtils.isEmpty(ranges)) {
|
if (CollectionUtils.isEmpty(ranges)) {
|
||||||
|
|
|
||||||
|
|
@ -114,11 +114,13 @@ public class MediaType extends MimeType implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public constant media type for {@code application/pdf}.
|
* Public constant media type for {@code application/pdf}.
|
||||||
|
* @since 4.3
|
||||||
*/
|
*/
|
||||||
public final static MediaType APPLICATION_PDF;
|
public final static MediaType APPLICATION_PDF;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A String equivalent of {@link MediaType#APPLICATION_PDF}.
|
* A String equivalent of {@link MediaType#APPLICATION_PDF}.
|
||||||
|
* @since 4.3
|
||||||
*/
|
*/
|
||||||
public final static String APPLICATION_PDF_VALUE = "application/pdf";
|
public final static String APPLICATION_PDF_VALUE = "application/pdf";
|
||||||
|
|
||||||
|
|
@ -194,11 +196,13 @@ public class MediaType extends MimeType implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public constant media type for {@code text/markdown}.
|
* Public constant media type for {@code text/markdown}.
|
||||||
|
* @since 4.3
|
||||||
*/
|
*/
|
||||||
public final static MediaType TEXT_MARKDOWN;
|
public final static MediaType TEXT_MARKDOWN;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A String equivalent of {@link MediaType#TEXT_MARKDOWN}.
|
* A String equivalent of {@link MediaType#TEXT_MARKDOWN}.
|
||||||
|
* @since 4.3
|
||||||
*/
|
*/
|
||||||
public final static String TEXT_MARKDOWN_VALUE = "text/markdown";
|
public final static String TEXT_MARKDOWN_VALUE = "text/markdown";
|
||||||
|
|
||||||
|
|
@ -296,6 +300,7 @@ public class MediaType extends MimeType implements Serializable {
|
||||||
* @param other the other media type
|
* @param other the other media type
|
||||||
* @param charset the character set
|
* @param charset the character set
|
||||||
* @throws IllegalArgumentException if any of the parameters contain illegal characters
|
* @throws IllegalArgumentException if any of the parameters contain illegal characters
|
||||||
|
* @since 4.3
|
||||||
*/
|
*/
|
||||||
public MediaType(MediaType other, Charset charset) {
|
public MediaType(MediaType other, Charset charset) {
|
||||||
super(other, charset);
|
super(other, charset);
|
||||||
|
|
|
||||||
|
|
@ -118,11 +118,11 @@ public class WebSocketExtension {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder str = new StringBuilder();
|
StringBuilder str = new StringBuilder();
|
||||||
str.append(this.name);
|
str.append(this.name);
|
||||||
for (String param : parameters.keySet()) {
|
for (Map.Entry<String, String> entry : this.parameters.entrySet()) {
|
||||||
str.append(';');
|
str.append(';');
|
||||||
str.append(param);
|
str.append(entry.getKey());
|
||||||
str.append('=');
|
str.append('=');
|
||||||
str.append(this.parameters.get(param));
|
str.append(entry.getValue());
|
||||||
}
|
}
|
||||||
return str.toString();
|
return str.toString();
|
||||||
}
|
}
|
||||||
|
|
@ -136,16 +136,17 @@ public class WebSocketExtension {
|
||||||
* @throws IllegalArgumentException if the string cannot be parsed
|
* @throws IllegalArgumentException if the string cannot be parsed
|
||||||
*/
|
*/
|
||||||
public static List<WebSocketExtension> parseExtensions(String extensions) {
|
public static List<WebSocketExtension> parseExtensions(String extensions) {
|
||||||
if (!StringUtils.hasText(extensions)) {
|
if (StringUtils.hasText(extensions)) {
|
||||||
return Collections.emptyList();
|
String[] tokens = StringUtils.tokenizeToStringArray(extensions, ",");
|
||||||
}
|
List<WebSocketExtension> result = new ArrayList<WebSocketExtension>(tokens.length);
|
||||||
else {
|
for (String token : tokens) {
|
||||||
List<WebSocketExtension> result = new ArrayList<>();
|
|
||||||
for (String token : StringUtils.tokenizeToStringArray(extensions, ",")) {
|
|
||||||
result.add(parseExtension(token));
|
result.add(parseExtension(token));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static WebSocketExtension parseExtension(String extension) {
|
private static WebSocketExtension parseExtension(String extension) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue