receive content data even though status code is not 2xx

This commit is contained in:
byeonggee.seo 2015-02-03 16:28:23 +09:00
parent 6f53719772
commit 753335726a
2 changed files with 22 additions and 12 deletions

View File

@ -87,13 +87,13 @@
| 205 ; Reset Content
| 206 ; Partial Content
*/
if (responseCode < 200 || responseCode >= 300)
{// something went wrong, abort the whole thing
// if (responseCode < 200 || responseCode >= 300)
// {// something went wrong, abort the whole thing
[connection cancel];
finish = true;
return;
}
// [connection cancel];
// finish = true;
// return;
// }
[responseData setLength:0];
}

View File

@ -260,8 +260,17 @@ public class Cocos2dxHttpURLConnection
}
static byte[] getResponseContent(HttpURLConnection http) {
try {
DataInputStream in = new DataInputStream(http.getInputStream());
DataInputStream in;
try {
in = new DataInputStream(http.getInputStream());
} catch (IOException e) {
in = new DataInputStream(http.getErrorStream());
} catch (Exception e) {
Log.e("Cocos2dxHttpURLConnection exception", e.toString());
return null;
}
try {
byte[] buffer = new byte[1024];
int size = 0;
ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
@ -272,12 +281,13 @@ public class Cocos2dxHttpURLConnection
byte retbuffer[] = bytestream.toByteArray();
bytestream.close();
return retbuffer;
} catch (Exception e) {
Log.e("Cocos2dxHttpURLConnection exception", e.toString());
}
} catch (Exception e) {
Log.e("Cocos2dxHttpURLConnection exception", e.toString());
}
return null;
}
static int getResponseCode(HttpURLConnection http) {
int code = 0;
try {