Fix in MockMultipartHttpServletRequest#getMultipartHeaders

Previously this method returned headers only when a Content-Type part header
was present. Now it is guaranteed to return headers (possibly empty) as long
as there is a MultipartFile or Part with the given name.

Closes gh-26501
This commit is contained in:
Rossen Stoyanchev
2021-02-03 21:55:29 +00:00
parent 7a329eba5b
commit c52526ad42
4 changed files with 68 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -60,9 +60,10 @@ public interface MultipartHttpServletRequest extends HttpServletRequest, Multipa
HttpHeaders getRequestHeaders();
/**
* Return the headers associated with the specified part of the multipart request.
* <p>If the underlying implementation supports access to headers, then all headers are returned.
* Otherwise, the returned headers will include a 'Content-Type' header at the very least.
* Return the headers for the specified part of the multipart request.
* <p>If the underlying implementation supports access to part headers,
* then all headers are returned. Otherwise, e.g. for a file upload, the
* returned headers may expose a 'Content-Type' if available.
*/
@Nullable
HttpHeaders getMultipartHeaders(String paramOrFileName);