File tree 1 file changed +11
-2
lines changed
src/main/java/ru/mystamps/web/feature/series
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -82,7 +82,12 @@ public DownloadResult download(String fileUrl) {
82
82
}
83
83
84
84
try (InputStream stream = new BufferedInputStream (conn .getInputStream ())) {
85
- Code validationResult = validateConnection (conn );
85
+ Code validationResult = validateResponseCode (conn );
86
+ if (validationResult != Code .SUCCESS ) {
87
+ return DownloadResult .failed (validationResult );
88
+ }
89
+
90
+ validationResult = validateContentType (conn );
86
91
if (validationResult != Code .SUCCESS ) {
87
92
return DownloadResult .failed (validationResult );
88
93
}
@@ -155,7 +160,7 @@ private static Code connect(HttpURLConnection conn) {
155
160
}
156
161
}
157
162
158
- private Code validateConnection (HttpURLConnection conn ) throws IOException {
163
+ private Code validateResponseCode (HttpURLConnection conn ) throws IOException {
159
164
int status = conn .getResponseCode ();
160
165
if (status == HttpURLConnection .HTTP_MOVED_TEMP
161
166
|| status == HttpURLConnection .HTTP_MOVED_PERM ) {
@@ -169,6 +174,10 @@ private Code validateConnection(HttpURLConnection conn) throws IOException {
169
174
return Code .UNEXPECTED_ERROR ;
170
175
}
171
176
177
+ return Code .SUCCESS ;
178
+ }
179
+
180
+ private Code validateContentType (HttpURLConnection conn ) {
172
181
String contentType = conn .getContentType ();
173
182
174
183
// We need only the first part from "text/html; charset=UTF-8"
You can’t perform that action at this time.
0 commit comments