mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Code server: fix proxying gzipped resources
This commit is contained in:
parent
eeca1a502c
commit
6790ad0818
|
@ -445,8 +445,11 @@ public class CodeServlet extends HttpServlet {
|
|||
sent = true;
|
||||
resp.setStatus(response.getStatus());
|
||||
|
||||
int length = -1;
|
||||
boolean isGzip = false;
|
||||
for (HttpField field : response.getHeaders()) {
|
||||
if (field.getName().toLowerCase().equals("location")) {
|
||||
String name = field.getName().toLowerCase();
|
||||
if (name.equals("location")) {
|
||||
String value = field.getValue();
|
||||
if (value.startsWith(proxyUrl)) {
|
||||
String relLocation = value.substring(proxyUrl.length());
|
||||
|
@ -454,8 +457,23 @@ public class CodeServlet extends HttpServlet {
|
|||
continue;
|
||||
}
|
||||
}
|
||||
if (name.equals("content-encoding")) {
|
||||
isGzip = true;
|
||||
continue;
|
||||
} else if (name.equals("content-length")) {
|
||||
try {
|
||||
length = Integer.parseInt(field.getValue());
|
||||
} catch (NumberFormatException e) {
|
||||
// do nothing
|
||||
}
|
||||
continue;
|
||||
}
|
||||
resp.addHeader(field.getName(), field.getValue());
|
||||
}
|
||||
|
||||
if (length > 0 && !isGzip) {
|
||||
resp.addHeader("Content-Length", String.valueOf(length));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user