File tree Expand file tree Collapse file tree 2 files changed +19
-8
lines changed
spring-test/src/main/java/org/springframework/mock/web
spring-web/src/test/java/org/springframework/mock/web/test Expand file tree Collapse file tree 2 files changed +19
-8
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2018 the original author or authors.
2
+ * Copyright 2002-2019 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.
@@ -124,16 +124,16 @@ public String getMultipartContentType(String paramOrFileName) {
124
124
if (file != null ) {
125
125
return file .getContentType ();
126
126
}
127
-
128
127
try {
129
128
Part part = getPart (paramOrFileName );
130
129
if (part != null ) {
131
130
return part .getContentType ();
132
131
}
133
- } catch (ServletException | IOException e ) {
134
- throw new IllegalStateException ("Cannot extract content type from multipart request." , e );
135
132
}
136
-
133
+ catch (ServletException | IOException ex ) {
134
+ // Should never happen (we're not actually parsing)
135
+ throw new IllegalStateException (ex );
136
+ }
137
137
return null ;
138
138
}
139
139
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright 2002-2018 the original author or authors.
2
+ * Copyright 2002-2019 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.
16
16
17
17
package org .springframework .mock .web .test ;
18
18
19
+ import java .io .IOException ;
19
20
import java .util .Collections ;
20
21
import java .util .Enumeration ;
21
22
import java .util .Iterator ;
22
23
import java .util .List ;
23
24
import java .util .Map ;
24
25
25
26
import javax .servlet .ServletContext ;
27
+ import javax .servlet .ServletException ;
28
+ import javax .servlet .http .Part ;
26
29
27
30
import org .springframework .http .HttpHeaders ;
28
31
import org .springframework .http .HttpMethod ;
@@ -121,9 +124,17 @@ public String getMultipartContentType(String paramOrFileName) {
121
124
if (file != null ) {
122
125
return file .getContentType ();
123
126
}
124
- else {
125
- return null ;
127
+ try {
128
+ Part part = getPart (paramOrFileName );
129
+ if (part != null ) {
130
+ return part .getContentType ();
131
+ }
132
+ }
133
+ catch (ServletException | IOException ex ) {
134
+ // Should never happen (we're not actually parsing)
135
+ throw new IllegalStateException (ex );
126
136
}
137
+ return null ;
127
138
}
128
139
129
140
@ Override
You can’t perform that action at this time.
0 commit comments