Skip to content
This repository was archived by the owner on Jan 17, 2023. It is now read-only.

Response body is null #6

Closed
tomislav opened this issue Nov 28, 2013 · 3 comments
Closed

Response body is null #6

tomislav opened this issue Nov 28, 2013 · 3 comments

Comments

@tomislav
Copy link

I'm getting (null) instead of the response body with AFLoggerLevelDebug. There is definitely a JSON response from the server because I can read it from the responseObject object. Also "Content-Length" is 18. Maybe because of POST ?

2013-11-28 20:14:11.497 eHaj[3464:70b] -[AFNetworkActivityLogger networkRequestDidStart:] line 108 $ POST 'http://xxxxxxxxxxxx.com/api/something': {
    "Accept-Language" = "en;q=1, fr;q=0.9, de;q=0.8, zh-Hans;q=0.7, zh-Hant;q=0.6, ja;q=0.5";
    Application = xxxxxx;
    Authorization = "Token token=\"xxxxxxxxxxxxxx\"";
    "Content-Type" = "application/json; charset=utf-8";
    "User-Agent" = "eKesh/1 (iPhone Simulator; iOS 7.0.3; Scale/2.00)";
    Version = "1.0";
} {"deviceID":"xxxxxxxxx"}

2013-11-28 20:14:11.523 eHaj[3464:70b] -[AFNetworkActivityLogger networkRequestDidFinish:] line 158 $ 200 'http://xxxxxxxxxxxx.com/api/something' [0.0258 s]: {
    Connection = "Keep-Alive";
    "Content-Length" = 18;
    "Content-Type" = "application/json";
    Date = "Thu, 28 Nov 2013 19:12:37 GMT";
    "Keep-Alive" = "timeout=2, max=100";
    Server = "Apache/2.2.16 (Debian)";
    Status = 200;
    "X-Powered-By" = "PHP/5.4.20-1~dotdeb.0";
} (null)
@smolskyaleksey
Copy link

I have the some issue. I use AFHTTPSessionManager. It happens because AFN send

[[NSNotificationCenter defaultCenter] postNotificationName:AFNetworkingTaskDidCompleteNotification object:task userInfo:userInfo];

and Logger check respondsToSelector, return NO

if ([[notification object] respondsToSelector:@selector(responseString)]) {
        responseString = [[notification object] responseString];
    }

@tlubinski
Copy link

I added the following in the logger, after it checks for the responseString selector (line 143):

  if (!responseString) {
    if (notification.userInfo) {
        responseString = [notification.userInfo objectForKey:AFNetworkingTaskDidCompleteSerializedResponseKey];
    }
  }

This solves the issue for me.

mattt added a commit that referenced this issue Jul 18, 2014
@mattt
Copy link
Contributor

mattt commented Jul 18, 2014

Fixed by 5ecf7c5.

@mattt mattt closed this as completed Jul 18, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants