Skip to content

Commit

Permalink
Merge pull request #544 from lidashuang/master
Browse files Browse the repository at this point in the history
Fixed not allow access data on code not equal 200
  • Loading branch information
SunLightJuly committed Aug 30, 2015
2 parents c0bea00 + bd137bf commit 4936aa7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,15 @@ static int getContentLeng(HttpURLConnection http) {

static byte[] getResponedString(HttpURLConnection http) {
try {
DataInputStream in = new DataInputStream(http.getInputStream());

int statusCode = http.getResponseCode();

DataInputStream in = null;
if(statusCode != 200 && statusCode != 201) {
in = new DataInputStream(http.getErrorStream());
}else{
in = new DataInputStream(http.getInputStream());
}

byte[] buffer = new byte[1024];
byte[] retBuf = null;
int len = in.read(buffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ void CCHTTPRequest::onRequest(void)
m_errorCode = code;
m_responseCode = code;
m_errorMessage = (code >= 200 && code < 300) ? "" : getResponedErrJava();
m_state = (code == 200) ? kCCHTTPRequestStateCompleted : kCCHTTPRequestStateFailed;
m_state = (code >= 200 && code < 600) ? kCCHTTPRequestStateCompleted : kCCHTTPRequestStateFailed;
m_curlState = kCCHTTPRequestCURLStateClosed;
}

Expand Down

0 comments on commit 4936aa7

Please sign in to comment.