Skip to content

Commit

Permalink
fix the customer user head
Browse files Browse the repository at this point in the history
  • Loading branch information
李杰 committed Sep 15, 2017
1 parent 2d55917 commit cf24ef8
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 3 deletions.
6 changes: 6 additions & 0 deletions JJNetwork.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
6199ADD41F2E27E9004573E3 /* APIRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 6199ADD31F2E27E9004573E3 /* APIRequest.m */; };
6199ADD71F2E2874004573E3 /* APIService.m in Sources */ = {isa = PBXBuildFile; fileRef = 6199ADD61F2E2874004573E3 /* APIService.m */; };
61B734B41F62A27D001549C1 /* APIServiceManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B734B31F62A27D001549C1 /* APIServiceManager.m */; };
61CEE54F1F6B68EB00726441 /* HttpHeadModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 61CEE54E1F6B68EB00726441 /* HttpHeadModule.m */; };
61E270F71F4DCEAB00834D0E /* NSString+MD5.m in Sources */ = {isa = PBXBuildFile; fileRef = 61E270F61F4DCEAB00834D0E /* NSString+MD5.m */; };
61E271061F52A5BA00834D0E /* PresentViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 61E271051F52A5BA00834D0E /* PresentViewController.m */; };
/* End PBXBuildFile section */
Expand Down Expand Up @@ -61,6 +62,8 @@
61B734B21F62A27D001549C1 /* APIServiceManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIServiceManager.h; sourceTree = "<group>"; };
61B734B31F62A27D001549C1 /* APIServiceManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APIServiceManager.m; sourceTree = "<group>"; };
61B734B51F65257B001549C1 /* APIModule.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = APIModule.h; sourceTree = "<group>"; };
61CEE54D1F6B68EB00726441 /* HttpHeadModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HttpHeadModule.h; sourceTree = "<group>"; };
61CEE54E1F6B68EB00726441 /* HttpHeadModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HttpHeadModule.m; sourceTree = "<group>"; };
61E270F51F4DCEAB00834D0E /* NSString+MD5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+MD5.h"; sourceTree = "<group>"; };
61E270F61F4DCEAB00834D0E /* NSString+MD5.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+MD5.m"; sourceTree = "<group>"; };
61E271041F52A5BA00834D0E /* PresentViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PresentViewController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -99,6 +102,8 @@
61237DB91F2F316E00889CD1 /* DemoAPIService.m */,
611E5A961F66D42800FAF5BD /* DomainModule.h */,
611E5A971F66D42800FAF5BD /* DomainModule.m */,
61CEE54D1F6B68EB00726441 /* HttpHeadModule.h */,
61CEE54E1F6B68EB00726441 /* HttpHeadModule.m */,
);
path = Demo;
sourceTree = "<group>";
Expand Down Expand Up @@ -361,6 +366,7 @@
61237DC01F30798400889CD1 /* APIManager.m in Sources */,
6199ADCA1F2E2618004573E3 /* AFNetworkImpl.m in Sources */,
61237DBA1F2F316E00889CD1 /* DemoAPIService.m in Sources */,
61CEE54F1F6B68EB00726441 /* HttpHeadModule.m in Sources */,
6199911B1F5C570A003AAED6 /* APIFileCache.m in Sources */,
611E5A981F66D42800FAF5BD /* DomainModule.m in Sources */,
61237DB71F2F315700889CD1 /* DemoRequest.m in Sources */,
Expand Down
14 changes: 14 additions & 0 deletions JJNetwork/Demo/HttpHeadModule.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// HttpHeadModule.h
// JJNetwork
//
// Created by Jezz on 2017/9/15.
// Copyright © 2017年 jezz. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "APIModule.h"

@interface HttpHeadModule : NSObject<APIModule>

@end
17 changes: 17 additions & 0 deletions JJNetwork/Demo/HttpHeadModule.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// HttpHeadModule.m
// JJNetwork
//
// Created by Jezz on 2017/9/15.
// Copyright © 2017年 jezz. All rights reserved.
//

#import "HttpHeadModule.h"

@implementation HttpHeadModule

- (NSDictionary*)keyMap{
return @{@"user-token":@"xxxxx",@"device-id":@"xxxxx"};
}

@end
2 changes: 2 additions & 0 deletions JJNetwork/PresentViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "PresentViewController.h"
#import "DemoAPIService.h"
#import "DomainModule.h"
#import "HttpHeadModule.h"

@interface PresentViewController ()<APIServiceProtocol>

Expand All @@ -32,6 +33,7 @@ - (void)viewDidLoad {
[self.view addSubview:button];

[APIService registerDomainIP:[[DomainModule alloc] init]];
[APIService registerHttpHeadField:[[HttpHeadModule alloc] init]];

[self.apiService userDetailInfo:100];

Expand Down
2 changes: 1 addition & 1 deletion JJNetwork/Source/APIService/APIService.m
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ - (NSString*)replaceDomainIPFromURL:(NSString*)url{
- (void)addHttpHeadFieldFromRequest:(NSMutableURLRequest**)request{
NSDictionary* heads = [APIServiceManager share].httpHeadField;
for (NSString* key in heads) {
[*request setValue:key forHTTPHeaderField:heads[key]];
[*request setValue:heads[key] forHTTPHeaderField:key];
}
}

Expand Down
6 changes: 4 additions & 2 deletions JJNetwork/Source/ThirdParty/AFNetworkImpl.m
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,15 @@ - (NSURLSessionTask*)sendHttpRequest:(NSURLRequest*)request parameter:(NSDiction
//NSMutableURLRequest
NSMutableURLRequest *mutableRequest = [[AFHTTPRequestSerializer serializer] requestWithMethod:method URLString:request.URL.absoluteString parameters:parameter error:nil];

mutableRequest.allHTTPHeaderFields = request.allHTTPHeaderFields;

AFURLSessionManager* sessionManager = [self sessionManager];

__weak typeof(self) weakSelf = self;
__weak typeof(target) weakTarget = target;
NSURLSessionDataTask *dataTask = [sessionManager dataTaskWithRequest:mutableRequest completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
__strong typeof(weakSelf) strongSelf = weakSelf;
__strong typeof(weakTarget) strongTarget = weakTarget;
__strong typeof(self) strongSelf = weakSelf;
__strong typeof(target) strongTarget = weakTarget;
if (error) {
NSLog(@"Get Error: %@", error);
[strongSelf performSelectorOnMainThread:selector withTarget:strongTarget withObject:error];
Expand Down

0 comments on commit cf24ef8

Please sign in to comment.