有的时候想要在request的header中添加一些自定义值,此时可以用AFNetworking进行
iOS端:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
[manager.requestSerializer setValue:@"value" forHTTPHeaderField:@"name"];
Django端:
request.META.get('HTTP_{your uppercased header name}')
具体的也就是:
request.META.get('HTTP_NAME')
就可以取出在iOS中设置的name值了