|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2018 the original author or authors. |
| 2 | + * Copyright 2002-2021 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
40 | 40 | * the {@linkplain #getInputStream() input stream} and {@linkplain #getReader() reader},
|
41 | 41 | * and allows this content to be retrieved via a {@link #getContentAsByteArray() byte array}.
|
42 | 42 | *
|
| 43 | + * <p>This class acts as an interceptor that only caches content as it is being |
| 44 | + * read but otherwise does not cause content to be read. That means if the request |
| 45 | + * content is not consumed, then the content is not cached, and cannot be |
| 46 | + * retrieved via {@link #getContentAsByteArray()}. |
| 47 | + * |
43 | 48 | * <p>Used e.g. by {@link org.springframework.web.filter.AbstractRequestLoggingFilter}.
|
44 | 49 | * Note: As of Spring Framework 5.0, this wrapper is built on the Servlet 3.1 API.
|
45 | 50 | *
|
| 51 | + * |
46 | 52 | * @author Juergen Hoeller
|
47 | 53 | * @author Brian Clozel
|
48 | 54 | * @since 4.1.3
|
@@ -184,6 +190,10 @@ private void writeRequestParametersToCachedContent() {
|
184 | 190 | /**
|
185 | 191 | * Return the cached request content as a byte array.
|
186 | 192 | * <p>The returned array will never be larger than the content cache limit.
|
| 193 | + * <p><strong>Note:</strong> The byte array returned from this method |
| 194 | + * reflects the amount of content that has has been read at the time when it |
| 195 | + * is called. If the application does not read the content, this method |
| 196 | + * returns an empty array. |
187 | 197 | * @see #ContentCachingRequestWrapper(HttpServletRequest, int)
|
188 | 198 | */
|
189 | 199 | public byte[] getContentAsByteArray() {
|
|
0 commit comments