AFNetworking请求设置请求头

    NSString *url = @"INPUT URL HERE";

    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

    manager.requestSerializer = [AFJSONRequestSerializer serializer];

    manager.responseSerializer = [AFJSONResponseSerializer serializer];

    [manager.requestSerializer setValue:@"qingqiu/json" forHTTPHeaderField:@"Accept"];

    [manager.requestSerializer setValue:@"zhelishiqingqiutou; charset=utf-8" forHTTPHeaderField:@"Content-Type"];

  //查看请求头

    NSLog(@"---%@",manager.requestSerializer.HTTPRequestHeaders);

 

    [manager POST:url parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject)

    {

        NSLog(@"成功 ");       

    }

    failure:^(AFHTTPRequestOperation *operation, NSError *error)

    {

         NSLog(@"失败 ");

    }];

posted @ 2015-09-11 17:37  阳光普照大地  阅读(1513)  评论(0编辑  收藏  举报