mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Fix HttpUrlConnection responseCode/responseMessage properties
This commit is contained in:
parent
de3727a4c0
commit
477f491b25
|
@ -87,34 +87,12 @@ public abstract class THttpURLConnection extends TURLConnection {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getResponseCode() throws IOException {
|
public int getResponseCode() throws IOException {
|
||||||
// Call getInputStream() first since getHeaderField() doesn't return
|
|
||||||
// exceptions
|
|
||||||
getInputStream();
|
getInputStream();
|
||||||
String response = getHeaderField(0);
|
|
||||||
if (response == null) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
response = response.trim();
|
|
||||||
int mark = response.indexOf(" ") + 1;
|
|
||||||
if (mark == 0) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
int last = mark + 3;
|
|
||||||
if (last > response.length()) {
|
|
||||||
last = response.length();
|
|
||||||
}
|
|
||||||
responseCode = Integer.parseInt(response.substring(mark, last));
|
|
||||||
if (last + 1 <= response.length()) {
|
|
||||||
responseMessage = response.substring(last + 1);
|
|
||||||
}
|
|
||||||
return responseCode;
|
return responseCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getResponseMessage() throws IOException {
|
public String getResponseMessage() throws IOException {
|
||||||
if (responseMessage != null) {
|
getInputStream();
|
||||||
return responseMessage;
|
|
||||||
}
|
|
||||||
getResponseCode();
|
|
||||||
return responseMessage;
|
return responseMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user