Http请求头加参数

//  DCCustomNSURLProtocol.h

//  DigitalCampus

//

//  Created by zh on 2017/8/24.

//  Copyright © 2017年 neusoft-edu. All rights reserved.

//

#import

@interfaceDCCustomNSURLProtocol :NSURLProtocol

@end


#import "DCCustomNSURLProtocol.h"

#import "DES3Util.h"//des加密文件

#import "DCAppDelegate.h"

#import "DCNewUser.h"//用户信息模型

#import "NSString+LSMD5.h"//md5加密文件

@implementationDCCustomNSURLProtocol

+(void)load{

    [NSURLProtocol registerClass:self];

}

+(BOOL)canInitWithRequest:(NSURLRequest*)request{

    if([requestisKindOfClass:[NSMutableURLRequestclass]]) {

        DCNewUser *user=[[DCAppDelegate sharedDelegate] loginUser];

        NSString*jsonBaseStr = [DES3Utilencrypt:user.ID_NUMBER];

        NSString*result;

        if(user.USER_PWD!=nil) {

            result = [NSStringmd5:user.USER_PWD];

        }

        [(id)requestsetValue:jsonBaseStrforHTTPHeaderField:@"idnumber"];

        [(id)requestsetValue:resultforHTTPHeaderField:@"enp"];

        [(id)request setValue:@"neumobile" forHTTPHeaderField:@"source"];


    }

return NO;

}

@end

你可能感兴趣的:(Http请求头加参数)