FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
IRWebAPIKit/IRWebAPIEngine+ExternalTransforms.m at develop · iridia/IRWebAPIKit · GitHub
iridia
IRWebAPIKit
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
IRWebAPIKit
/
IRWebAPIEngine+ExternalTransforms.m
Copy path
More file actions
More file actions
Latest commit
History
History
History
81 lines (54 loc) · 2.91 KB
Breadcrumbs
IRWebAPIKit
/
IRWebAPIEngine+ExternalTransforms.m
Copy path
File metadata and controls
81 lines (54 loc) · 2.91 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
//
IRWebAPIEngine+ExternalTransforms.m
//
IRWebAPIKit
//
//
Created by Evadne Wu on 11/14/11.
//
Copyright (c) 2011 Iridia Productions. All rights reserved.
//
#
import
"
IRWebAPIEngine+ExternalTransforms.h
"
@interface
IRWebAPIEngine
(ExternalTransforms_KnownPrivate)
- (
NSDictionary
*)
baseRequestContextWithMethodName
:
(
NSString
*)
inMethodName
arguments
:
(
NSDictionary
*)
inArgumentsOrNil
options
:
(
NSDictionary
*)
inOptionsOrNil
;
- (
NSDictionary
*)
requestContextByTransformingContext
:
(
NSDictionary
*)
inContext
forMethodNamed
:
(
NSString
*)
inMethodName
;
- (
NSURLRequest
*)
requestWithContext
:
(
NSDictionary
*)
inContext
;
@end
@implementation
IRWebAPIEngine
(ExternalTransforms)
- (
NSURLRequest
*)
transformedRequestWithRequest
:
(
NSURLRequest
*)
aRequest
usingMethodName
:
(
NSString
*)
aName
{
NSDictionary
*baseContext = [
self
baseRequestContextWithMethodName:
aName
arguments:
nil
options:
nil
];
NSURL
*baseURL = [baseContext
objectForKey:
kIRWebAPIEngineRequestHTTPBaseURL
];
NSDictionary
*headerFields = [baseContext
objectForKey:
kIRWebAPIEngineRequestHTTPHeaderFields
];
NSDictionary
*arguments = [baseContext
objectForKey:
kIRWebAPIEngineRequestHTTPQueryParameters
];
NSData
*httpBody = [baseContext
objectForKey:
kIRWebAPIEngineRequestHTTPBody
];
NSString
*httpMethod = [baseContext
objectForKey:
kIRWebAPIEngineRequestHTTPMethod
];
IRWebAPIResponseParser responseParser = [baseContext
objectForKey:
kIRWebAPIEngineParser
];
if
([[aRequest
allHTTPHeaderFields
]
count
])
headerFields = [aRequest
allHTTPHeaderFields
];
if
([aRequest
HTTPBody
])
httpBody = [aRequest
HTTPBody
];
if
([aRequest
URL
]) {
NSURL
*givenURL = [aRequest
URL
];
NSString
*baseURLString = [[
NSArray
arrayWithObjects:
[givenURL
scheme
] ? [[givenURL
scheme
]
stringByAppendingString:
@"
://
"
]:
@"
"
,
[givenURL
host
] ? [givenURL
host
] :
@"
"
,
[givenURL
port
] ? [
@"
:
"
stringByAppendingString:
[[givenURL
port
]
stringValue
]] :
@"
"
,
[givenURL
path
] ? [givenURL
path
] :
@"
"
,
//
[givenURL query] ? [@"?" stringByAppendingString:[givenURL query]] : @"",
//
[givenURL fragment] ? [@"#" stringByAppendingString:[givenURL fragment]] : @"",
nil
]
componentsJoinedByString:
@"
"
];
if
([givenURL
query
])
arguments =
IRQueryParametersFromString
([givenURL
query
]);
baseURL = [
NSURL
URLWithString:
baseURLString];
}
NSDictionary
*inferredContext = [
NSDictionary
dictionaryWithObjectsAndKeys:
baseURL,
kIRWebAPIEngineRequestHTTPBaseURL
,
headerFields,
kIRWebAPIEngineRequestHTTPHeaderFields
,
arguments,
kIRWebAPIEngineRequestHTTPQueryParameters
,
httpBody,
kIRWebAPIEngineRequestHTTPBody
,
httpMethod,
kIRWebAPIEngineRequestHTTPMethod
,
responseParser,
kIRWebAPIEngineParser
,
aName,
kIRWebAPIEngineIncomingMethodName
,
nil
];
NSDictionary
*transformedContext = [
self
requestContextByTransformingContext:
inferredContext
forMethodNamed:
aName];
NSURLRequest
*returnedRequest = [
self
requestWithContext:
transformedContext];
return
returnedRequest;
}
@end
Back
|
FazBrowse Home
|
New Git URL