mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Perform HTTP request as late as possible
This commit is contained in:
parent
bbf9faee5b
commit
ec3724b2bc
|
@ -59,7 +59,7 @@ after_success: >
|
||||||
export TEAVM_FTP_HOST
|
export TEAVM_FTP_HOST
|
||||||
export TEAVM_FTP_LOGIN
|
export TEAVM_FTP_LOGIN
|
||||||
export TEAVM_FTP_PASSWORD
|
export TEAVM_FTP_PASSWORD
|
||||||
mvn deploy -Dteavm.build.all=false -DskipTests --settings travis-settings.xml -P deploy-to-bintray && \
|
mvn deploy -Dteavm.build.all=false -DskipTests --settings travis-settings.xml -P deploy-to-bintray -P with-idea && \
|
||||||
./upload-files.sh
|
./upload-files.sh
|
||||||
fi
|
fi
|
||||||
after_script:
|
after_script:
|
||||||
|
|
|
@ -41,6 +41,7 @@ public class TXHRURLConnection extends THttpURLConnection {
|
||||||
private String[] responseHeaderKeys;
|
private String[] responseHeaderKeys;
|
||||||
private String[] responseHeaderValues;
|
private String[] responseHeaderValues;
|
||||||
private Map<String, List<String>> headerFields = new HashMap<>();
|
private Map<String, List<String>> headerFields = new HashMap<>();
|
||||||
|
private boolean requestPerformed;
|
||||||
|
|
||||||
public TXHRURLConnection(TURL url) {
|
public TXHRURLConnection(TURL url) {
|
||||||
super(url);
|
super(url);
|
||||||
|
@ -72,10 +73,13 @@ public class TXHRURLConnection extends THttpURLConnection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xhr.setResponseType("arraybuffer");
|
xhr.setResponseType("arraybuffer");
|
||||||
try {
|
connected = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void performRequestIfNecessary() {
|
||||||
|
if (!requestPerformed) {
|
||||||
|
requestPerformed = true;
|
||||||
performRequest();
|
performRequest();
|
||||||
} finally {
|
|
||||||
connected = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +170,7 @@ public class TXHRURLConnection extends THttpURLConnection {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHeaderFieldKey(int posn) {
|
public String getHeaderFieldKey(int posn) {
|
||||||
|
performRequestIfNecessary();
|
||||||
if (responseHeaderKeys == null || posn >= responseHeaderKeys.length) {
|
if (responseHeaderKeys == null || posn >= responseHeaderKeys.length) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -174,6 +179,7 @@ public class TXHRURLConnection extends THttpURLConnection {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHeaderField(int pos) {
|
public String getHeaderField(int pos) {
|
||||||
|
performRequestIfNecessary();
|
||||||
if (responseHeaderValues == null || pos >= responseHeaderValues.length) {
|
if (responseHeaderValues == null || pos >= responseHeaderValues.length) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -182,6 +188,7 @@ public class TXHRURLConnection extends THttpURLConnection {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getHeaderField(String key) {
|
public String getHeaderField(String key) {
|
||||||
|
performRequestIfNecessary();
|
||||||
return responseHeaders != null ? responseHeaders.get(key.toLowerCase()) : null;
|
return responseHeaders != null ? responseHeaders.get(key.toLowerCase()) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,6 +200,7 @@ public class TXHRURLConnection extends THttpURLConnection {
|
||||||
@Override
|
@Override
|
||||||
public InputStream getInputStream() throws IOException {
|
public InputStream getInputStream() throws IOException {
|
||||||
connect();
|
connect();
|
||||||
|
performRequestIfNecessary();
|
||||||
|
|
||||||
int responseGroup = responseCode / 100;
|
int responseGroup = responseCode / 100;
|
||||||
if (responseGroup == 4 || responseGroup == 5) {
|
if (responseGroup == 4 || responseGroup == 5) {
|
||||||
|
@ -203,6 +211,20 @@ public class TXHRURLConnection extends THttpURLConnection {
|
||||||
return inputStream;
|
return inputStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getResponseCode() throws IOException {
|
||||||
|
connect();
|
||||||
|
performRequestIfNecessary();
|
||||||
|
return super.getResponseCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getResponseMessage() throws IOException {
|
||||||
|
connect();
|
||||||
|
performRequestIfNecessary();
|
||||||
|
return super.getResponseMessage();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getErrorStream() {
|
public InputStream getErrorStream() {
|
||||||
return errorStream;
|
return errorStream;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user