Efficient STOMP content-length header check
Issue: SPR-14747
This commit is contained in:
@@ -30,21 +30,21 @@ import org.springframework.messaging.simp.SimpMessageHeaderAccessor;
|
|||||||
import org.springframework.messaging.simp.SimpMessageType;
|
import org.springframework.messaging.simp.SimpMessageType;
|
||||||
import org.springframework.messaging.support.MessageHeaderAccessor;
|
import org.springframework.messaging.support.MessageHeaderAccessor;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.MimeType;
|
import org.springframework.util.MimeType;
|
||||||
import org.springframework.util.MimeTypeUtils;
|
import org.springframework.util.MimeTypeUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@code MessageHeaderAccessor} to use when creating a {@code Message} from a
|
* A {@code MessageHeaderAccessor} to use when creating a {@code Message} from
|
||||||
* decoded STOMP frame, or when encoding a {@code Message} to a STOMP frame.
|
* a decoded STOMP frame, or when encoding a {@code Message} to a STOMP frame.
|
||||||
*
|
*
|
||||||
* <p>When created from STOMP frame content, the actual STOMP headers are stored
|
* <p>When created from STOMP frame content, the actual STOMP headers are
|
||||||
* in the native header sub-map managed by the parent class
|
* stored in the native header sub-map managed by the parent class
|
||||||
* {@link org.springframework.messaging.support.NativeMessageHeaderAccessor}
|
* {@link org.springframework.messaging.support.NativeMessageHeaderAccessor}
|
||||||
* while the parent class
|
* while the parent class {@link SimpMessageHeaderAccessor} manages common
|
||||||
* {@link org.springframework.messaging.simp.SimpMessageHeaderAccessor} manages
|
* processing headers some of which are based on STOMP headers
|
||||||
* common processing headers some of which are based on STOMP headers (e.g.
|
* (e.g. destination, content-type, etc).
|
||||||
* destination, content-type, etc).
|
|
||||||
*
|
*
|
||||||
* <p>An instance of this class can also be created by wrapping an existing
|
* <p>An instance of this class can also be created by wrapping an existing
|
||||||
* {@code Message}. That message may have been created with the more generic
|
* {@code Message}. That message may have been created with the more generic
|
||||||
@@ -503,12 +503,8 @@ public class StompHeaderAccessor extends SimpMessageHeaderAccessor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Integer getContentLength(Map<String, List<String>> nativeHeaders) {
|
public static Integer getContentLength(Map<String, List<String>> nativeHeaders) {
|
||||||
if (nativeHeaders.containsKey(STOMP_CONTENT_LENGTH_HEADER)) {
|
List<String> values = nativeHeaders.get(STOMP_CONTENT_LENGTH_HEADER);
|
||||||
List<String> values = nativeHeaders.get(STOMP_CONTENT_LENGTH_HEADER);
|
return (!CollectionUtils.isEmpty(values) ? Integer.valueOf(values.get(0)) : null);
|
||||||
String value = (values != null ? values.get(0) : null);
|
|
||||||
return Integer.valueOf(value);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user