AFNetWorking请求头的设置

  1. AFHTTPRequestOperationManager*manager=[AFHTTPRequestOperationManagermanager];
  2. manager.securityPolicy=[AFSecurityPolicypolicyWithPinningMode:AFSSLPinningModeNone];
  3. manager.requestSerializer=[AFJSONRequestSerializerserializer];
  4. manager.responseSerializer=[AFJSONResponseSerializerserializer];
  5. [manager.requestSerializersetValue:@"application/json"forHTTPHeaderField:@"Accept"];
  6. [manager.requestSerializersetValue:@"application/json;charset=utf-8"forHTTPHeaderField:@"Content-Type"]; 


还有一种就是直接进入AFN源码添加请求头,这样就可以不用每次都设置了

 self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil];

  AFN的AFURLResponseSerialization.m中有这样一个请求头的设置,直接全局搜索,然后添加想要的请求头格式就可以了!

你可能感兴趣的:(AFNetWorking请求头的设置)