|
1 | 1 | package me.itzg.helpers.http; |
2 | 2 |
|
3 | | -import static io.netty.handler.codec.http.HttpHeaderNames.*; |
| 3 | +import static io.netty.handler.codec.http.HttpHeaderNames.ACCEPT; |
| 4 | +import static io.netty.handler.codec.http.HttpHeaderNames.AUTHORIZATION; |
| 5 | +import static io.netty.handler.codec.http.HttpHeaderNames.CONTENT_TYPE; |
4 | 6 |
|
5 | | -import com.fasterxml.jackson.databind.ObjectMapper; |
6 | | -import io.netty.handler.codec.http.HttpHeaderNames; |
7 | | -import io.netty.handler.codec.http.HttpHeaders; |
8 | | -import io.netty.handler.codec.http.HttpStatusClass; |
9 | | -import io.netty.handler.codec.http.HttpUtil; |
10 | 7 | import java.net.URI; |
11 | 8 | import java.net.URISyntaxException; |
12 | 9 | import java.nio.charset.StandardCharsets; |
|
25 | 22 | import java.util.regex.Matcher; |
26 | 23 | import java.util.regex.Pattern; |
27 | 24 | import java.util.stream.Collectors; |
| 25 | + |
| 26 | +import org.slf4j.Logger; |
| 27 | + |
| 28 | +import com.fasterxml.jackson.databind.ObjectMapper; |
| 29 | + |
| 30 | +import io.netty.handler.codec.http.HttpHeaderNames; |
| 31 | +import io.netty.handler.codec.http.HttpHeaders; |
| 32 | +import io.netty.handler.codec.http.HttpStatusClass; |
| 33 | +import io.netty.handler.codec.http.HttpUtil; |
28 | 34 | import lombok.extern.slf4j.Slf4j; |
29 | 35 | import me.itzg.helpers.errors.GenericException; |
30 | 36 | import me.itzg.helpers.http.SharedFetch.Options; |
31 | 37 | import me.itzg.helpers.json.ObjectMappers; |
32 | | -import org.slf4j.Logger; |
33 | 38 | import reactor.core.publisher.Mono; |
34 | 39 | import reactor.netty.ByteBufMono; |
35 | 40 | import reactor.netty.Connection; |
@@ -246,12 +251,14 @@ protected boolean notExpectedContentType(HttpClientResponse resp) { |
246 | 251 |
|
247 | 252 | /** |
248 | 253 | * CDN providers like bukkit don't support HEAD and respond with a 200 OK and redirect to a path like /error?aspxerrorpath=/projects/worldedit/files/latest |
| 254 | + * Also, S3 object storage services generally don't support HEAD and respond with 403 Forbidden when trying to fetch an object. |
249 | 255 | * @param resp the response to evaluate |
250 | 256 | * @return true if this response to a HEAD seems to indicate it is not supported |
251 | 257 | */ |
252 | 258 | protected static boolean isHeadUnsupportedResponse(HttpClientResponse resp) { |
253 | | - return resp.path().equals("error") && |
254 | | - HttpUtil.getMimeType(resp.responseHeaders().get(HttpHeaderNames.CONTENT_TYPE.toString())).equals("text/html"); |
| 259 | + return resp.status().code() == 403 || |
| 260 | + (resp.path().equals("error") && |
| 261 | + HttpUtil.getMimeType(resp.responseHeaders().get(HttpHeaderNames.CONTENT_TYPE.toString())).equals("text/html")); |
255 | 262 | } |
256 | 263 |
|
257 | 264 | protected <R> Mono<R> failedContentTypeMono(HttpClientResponse resp) { |
|
0 commit comments