├── .gitignore
├── .travis.yml
├── LICENSE.md
├── README.md
├── cURLLook-OSX
├── Info.plist
└── cURLLook-OSX.h
├── cURLLook-iOS
├── Info.plist
└── cURLLook-iOS.h
├── cURLLook.podspec
├── cURLLook.xcodeproj
├── project.pbxproj
├── project.xcworkspace
│ └── contents.xcworkspacedata
└── xcshareddata
│ └── xcschemes
│ ├── cURLLook-OSX.xcscheme
│ └── cURLLook-iOS.xcscheme
└── cURLLook
└── NSURLRequestCURLRepresentation.swift
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | .DS_Store
3 | */build/*
4 | *.pbxuser
5 | !default.pbxuser
6 | *.mode1v3
7 | !default.mode1v3
8 | *.mode2v3
9 | !default.mode2v3
10 | *.perspectivev3
11 | !default.perspectivev3
12 | xcuserdata
13 | *.xccheckout
14 | profile
15 | *.moved-aside
16 | DerivedData
17 | .idea/
18 | *.hmap
19 |
20 | #CocoaPods
21 | Pods
22 | Podfile.lock
23 |
24 | #
25 | Carthage/
26 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: objective-c
2 | osx_image: xcode7
3 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Daniel Duan
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | This μ-framework serializes your `NSURLRequest` object to
2 | a [cURL](http://curl.haxx.se) command, so you can convey to a backend person
3 | clearly what kind of HTTP request your code is making.
4 |
5 | ```swift
6 | let request: NSURLRequest
7 | let aSession: NSURLSession
8 |
9 | // … after you created your URL session and request, this will give you
10 | // a cURL command that also performs this request
11 | print(request.cURLRepresentation(withURLSession: aSession))
12 |
13 |
14 | // alternatively, you can use this convenient proprety without a session:
15 | print(request.cURLString)
16 |
17 | ```
18 |
19 | # Install
20 |
21 | ## Carthage (recommended)
22 |
23 | Include the following in your Cartfile:
24 |
25 | github "dduan/cURLLook"
26 |
27 | ## CocoaPods
28 |
29 | The usual way:
30 |
31 | platform :ios, '8.0'
32 | use_frameworks!
33 |
34 | target 'MyApp' do
35 | pod 'cURLLook'
36 | end
37 |
38 | # Credit
39 |
40 | The code is an adaption from
41 | [Alamofile](https://github.com/Alamofire/Alamofire)
42 |
--------------------------------------------------------------------------------
/cURLLook-OSX/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/cURLLook-OSX/cURLLook-OSX.h:
--------------------------------------------------------------------------------
1 | //
2 | // cURLLook-OSX.h
3 | // cURLLook-OSX
4 | //
5 | // Created by Daniel Duan on 9/5/15.
6 | //
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for cURLLook-OSX.
12 | FOUNDATION_EXPORT double cURLLook_OSXVersionNumber;
13 |
14 | //! Project version string for cURLLook-OSX.
15 | FOUNDATION_EXPORT const unsigned char cURLLook_OSXVersionString[];
16 |
17 | // In this header, you should import all the public headers of your framework using statements like #import
18 |
19 |
20 |
--------------------------------------------------------------------------------
/cURLLook-iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(CURRENT_PROJECT_VERSION)
23 | NSPrincipalClass
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/cURLLook-iOS/cURLLook-iOS.h:
--------------------------------------------------------------------------------
1 | //
2 | // cURLLook-iOS.h
3 | // cURLLook-iOS
4 | //
5 | // Created by Daniel Duan on 9/5/15.
6 | //
7 | //
8 |
9 | #import
10 |
11 | //! Project version number for cURLLook-iOS.
12 | FOUNDATION_EXPORT double cURLLook_iOSVersionNumber;
13 |
14 | //! Project version string for cURLLook-iOS.
15 | FOUNDATION_EXPORT const unsigned char cURLLook_iOSVersionString[];
16 |
17 | // In this header, you should import all the public headers of your framework using statements like #import
18 |
19 |
20 |
--------------------------------------------------------------------------------
/cURLLook.podspec:
--------------------------------------------------------------------------------
1 |
2 | Pod::Spec.new do |s|
3 |
4 | s.name = "cURLLook"
5 | s.version = "0.0.2"
6 | s.summary = "Make your NSURLRequest a cURL command"
7 |
8 | s.description = <<-DESC
9 | This μ-framework serializes your NSURLRequest object to
10 | a cURL command, so you can convey to a backend person
11 | clearly what kind of HTTP request your code is making.
12 |
13 | DESC
14 |
15 | s.homepage = "https://github.com/dduan/cURLLook"
16 |
17 | s.license = { :type => "MIT", :file => "LICENSE.md" }
18 | s.author = { "Daniel Duan" => "daniel@duan.org" }
19 | s.social_media_url = "https://twitter.com/Daniel_Duan"
20 |
21 | s.ios.deployment_target = "8.0"
22 | s.osx.deployment_target = "10.10"
23 |
24 | s.source = { :git => "https://github.com/dduan/cURLLook.git", :tag => "v#{s.version}" }
25 |
26 | s.source_files = "cURLLook", "cURLLook/**/*.{swift}"
27 |
28 | end
29 |
--------------------------------------------------------------------------------
/cURLLook.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 94ABF6DD1B9BB5F9009A22E3 /* cURLLook-iOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 94ABF6DC1B9BB5F9009A22E3 /* cURLLook-iOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
11 | 94ABF6EA1B9BB623009A22E3 /* cURLLook-OSX.h in Headers */ = {isa = PBXBuildFile; fileRef = 94ABF6E91B9BB623009A22E3 /* cURLLook-OSX.h */; settings = {ATTRIBUTES = (Public, ); }; };
12 | 94ABF6EF1B9BB62B009A22E3 /* NSURLRequestCURLRepresentation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94ABF6D31B9BB3A0009A22E3 /* NSURLRequestCURLRepresentation.swift */; };
13 | 94ABF6F01B9BB62B009A22E3 /* NSURLRequestCURLRepresentation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94ABF6D31B9BB3A0009A22E3 /* NSURLRequestCURLRepresentation.swift */; };
14 | /* End PBXBuildFile section */
15 |
16 | /* Begin PBXFileReference section */
17 | 94ABF6D31B9BB3A0009A22E3 /* NSURLRequestCURLRepresentation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSURLRequestCURLRepresentation.swift; sourceTree = ""; };
18 | 94ABF6DA1B9BB5F9009A22E3 /* cURLLook.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = cURLLook.framework; sourceTree = BUILT_PRODUCTS_DIR; };
19 | 94ABF6DC1B9BB5F9009A22E3 /* cURLLook-iOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "cURLLook-iOS.h"; sourceTree = ""; };
20 | 94ABF6DE1B9BB5F9009A22E3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
21 | 94ABF6E71B9BB623009A22E3 /* cURLLook.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = cURLLook.framework; sourceTree = BUILT_PRODUCTS_DIR; };
22 | 94ABF6E91B9BB623009A22E3 /* cURLLook-OSX.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "cURLLook-OSX.h"; sourceTree = ""; };
23 | 94ABF6EB1B9BB623009A22E3 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
24 | /* End PBXFileReference section */
25 |
26 | /* Begin PBXFrameworksBuildPhase section */
27 | 94ABF6D61B9BB5F9009A22E3 /* Frameworks */ = {
28 | isa = PBXFrameworksBuildPhase;
29 | buildActionMask = 2147483647;
30 | files = (
31 | );
32 | runOnlyForDeploymentPostprocessing = 0;
33 | };
34 | 94ABF6E31B9BB623009A22E3 /* Frameworks */ = {
35 | isa = PBXFrameworksBuildPhase;
36 | buildActionMask = 2147483647;
37 | files = (
38 | );
39 | runOnlyForDeploymentPostprocessing = 0;
40 | };
41 | /* End PBXFrameworksBuildPhase section */
42 |
43 | /* Begin PBXGroup section */
44 | 94ABF6BE1B9BB366009A22E3 = {
45 | isa = PBXGroup;
46 | children = (
47 | 94ABF6CA1B9BB366009A22E3 /* cURLLook */,
48 | 94ABF6DB1B9BB5F9009A22E3 /* cURLLook-iOS */,
49 | 94ABF6E81B9BB623009A22E3 /* cURLLook-OSX */,
50 | 94ABF6C91B9BB366009A22E3 /* Products */,
51 | );
52 | sourceTree = "";
53 | };
54 | 94ABF6C91B9BB366009A22E3 /* Products */ = {
55 | isa = PBXGroup;
56 | children = (
57 | 94ABF6DA1B9BB5F9009A22E3 /* cURLLook.framework */,
58 | 94ABF6E71B9BB623009A22E3 /* cURLLook.framework */,
59 | );
60 | name = Products;
61 | sourceTree = "";
62 | };
63 | 94ABF6CA1B9BB366009A22E3 /* cURLLook */ = {
64 | isa = PBXGroup;
65 | children = (
66 | 94ABF6D31B9BB3A0009A22E3 /* NSURLRequestCURLRepresentation.swift */,
67 | );
68 | path = cURLLook;
69 | sourceTree = "";
70 | };
71 | 94ABF6DB1B9BB5F9009A22E3 /* cURLLook-iOS */ = {
72 | isa = PBXGroup;
73 | children = (
74 | 94ABF6DC1B9BB5F9009A22E3 /* cURLLook-iOS.h */,
75 | 94ABF6DE1B9BB5F9009A22E3 /* Info.plist */,
76 | );
77 | path = "cURLLook-iOS";
78 | sourceTree = "";
79 | };
80 | 94ABF6E81B9BB623009A22E3 /* cURLLook-OSX */ = {
81 | isa = PBXGroup;
82 | children = (
83 | 94ABF6E91B9BB623009A22E3 /* cURLLook-OSX.h */,
84 | 94ABF6EB1B9BB623009A22E3 /* Info.plist */,
85 | );
86 | path = "cURLLook-OSX";
87 | sourceTree = "";
88 | };
89 | /* End PBXGroup section */
90 |
91 | /* Begin PBXHeadersBuildPhase section */
92 | 94ABF6D71B9BB5F9009A22E3 /* Headers */ = {
93 | isa = PBXHeadersBuildPhase;
94 | buildActionMask = 2147483647;
95 | files = (
96 | 94ABF6DD1B9BB5F9009A22E3 /* cURLLook-iOS.h in Headers */,
97 | );
98 | runOnlyForDeploymentPostprocessing = 0;
99 | };
100 | 94ABF6E41B9BB623009A22E3 /* Headers */ = {
101 | isa = PBXHeadersBuildPhase;
102 | buildActionMask = 2147483647;
103 | files = (
104 | 94ABF6EA1B9BB623009A22E3 /* cURLLook-OSX.h in Headers */,
105 | );
106 | runOnlyForDeploymentPostprocessing = 0;
107 | };
108 | /* End PBXHeadersBuildPhase section */
109 |
110 | /* Begin PBXNativeTarget section */
111 | 94ABF6D91B9BB5F9009A22E3 /* cURLLook-iOS */ = {
112 | isa = PBXNativeTarget;
113 | buildConfigurationList = 94ABF6DF1B9BB5F9009A22E3 /* Build configuration list for PBXNativeTarget "cURLLook-iOS" */;
114 | buildPhases = (
115 | 94ABF6D51B9BB5F9009A22E3 /* Sources */,
116 | 94ABF6D61B9BB5F9009A22E3 /* Frameworks */,
117 | 94ABF6D71B9BB5F9009A22E3 /* Headers */,
118 | 94ABF6D81B9BB5F9009A22E3 /* Resources */,
119 | );
120 | buildRules = (
121 | );
122 | dependencies = (
123 | );
124 | name = "cURLLook-iOS";
125 | productName = "cURLLook-iOS";
126 | productReference = 94ABF6DA1B9BB5F9009A22E3 /* cURLLook.framework */;
127 | productType = "com.apple.product-type.framework";
128 | };
129 | 94ABF6E61B9BB623009A22E3 /* cURLLook-OSX */ = {
130 | isa = PBXNativeTarget;
131 | buildConfigurationList = 94ABF6EC1B9BB623009A22E3 /* Build configuration list for PBXNativeTarget "cURLLook-OSX" */;
132 | buildPhases = (
133 | 94ABF6E21B9BB623009A22E3 /* Sources */,
134 | 94ABF6E31B9BB623009A22E3 /* Frameworks */,
135 | 94ABF6E41B9BB623009A22E3 /* Headers */,
136 | 94ABF6E51B9BB623009A22E3 /* Resources */,
137 | );
138 | buildRules = (
139 | );
140 | dependencies = (
141 | );
142 | name = "cURLLook-OSX";
143 | productName = "cURLLook-OSX";
144 | productReference = 94ABF6E71B9BB623009A22E3 /* cURLLook.framework */;
145 | productType = "com.apple.product-type.framework";
146 | };
147 | /* End PBXNativeTarget section */
148 |
149 | /* Begin PBXProject section */
150 | 94ABF6BF1B9BB366009A22E3 /* Project object */ = {
151 | isa = PBXProject;
152 | attributes = {
153 | LastSwiftUpdateCheck = 0700;
154 | LastUpgradeCheck = 0700;
155 | TargetAttributes = {
156 | 94ABF6D91B9BB5F9009A22E3 = {
157 | CreatedOnToolsVersion = 7.0;
158 | };
159 | 94ABF6E61B9BB623009A22E3 = {
160 | CreatedOnToolsVersion = 7.0;
161 | };
162 | };
163 | };
164 | buildConfigurationList = 94ABF6C21B9BB366009A22E3 /* Build configuration list for PBXProject "cURLLook" */;
165 | compatibilityVersion = "Xcode 3.2";
166 | developmentRegion = English;
167 | hasScannedForEncodings = 0;
168 | knownRegions = (
169 | en,
170 | );
171 | mainGroup = 94ABF6BE1B9BB366009A22E3;
172 | productRefGroup = 94ABF6C91B9BB366009A22E3 /* Products */;
173 | projectDirPath = "";
174 | projectRoot = "";
175 | targets = (
176 | 94ABF6D91B9BB5F9009A22E3 /* cURLLook-iOS */,
177 | 94ABF6E61B9BB623009A22E3 /* cURLLook-OSX */,
178 | );
179 | };
180 | /* End PBXProject section */
181 |
182 | /* Begin PBXResourcesBuildPhase section */
183 | 94ABF6D81B9BB5F9009A22E3 /* Resources */ = {
184 | isa = PBXResourcesBuildPhase;
185 | buildActionMask = 2147483647;
186 | files = (
187 | );
188 | runOnlyForDeploymentPostprocessing = 0;
189 | };
190 | 94ABF6E51B9BB623009A22E3 /* Resources */ = {
191 | isa = PBXResourcesBuildPhase;
192 | buildActionMask = 2147483647;
193 | files = (
194 | );
195 | runOnlyForDeploymentPostprocessing = 0;
196 | };
197 | /* End PBXResourcesBuildPhase section */
198 |
199 | /* Begin PBXSourcesBuildPhase section */
200 | 94ABF6D51B9BB5F9009A22E3 /* Sources */ = {
201 | isa = PBXSourcesBuildPhase;
202 | buildActionMask = 2147483647;
203 | files = (
204 | 94ABF6EF1B9BB62B009A22E3 /* NSURLRequestCURLRepresentation.swift in Sources */,
205 | );
206 | runOnlyForDeploymentPostprocessing = 0;
207 | };
208 | 94ABF6E21B9BB623009A22E3 /* Sources */ = {
209 | isa = PBXSourcesBuildPhase;
210 | buildActionMask = 2147483647;
211 | files = (
212 | 94ABF6F01B9BB62B009A22E3 /* NSURLRequestCURLRepresentation.swift in Sources */,
213 | );
214 | runOnlyForDeploymentPostprocessing = 0;
215 | };
216 | /* End PBXSourcesBuildPhase section */
217 |
218 | /* Begin XCBuildConfiguration section */
219 | 94ABF6CE1B9BB366009A22E3 /* Debug */ = {
220 | isa = XCBuildConfiguration;
221 | buildSettings = {
222 | ALWAYS_SEARCH_USER_PATHS = NO;
223 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
224 | CLANG_CXX_LIBRARY = "libc++";
225 | CLANG_ENABLE_MODULES = YES;
226 | CLANG_ENABLE_OBJC_ARC = YES;
227 | CLANG_WARN_BOOL_CONVERSION = YES;
228 | CLANG_WARN_CONSTANT_CONVERSION = YES;
229 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
230 | CLANG_WARN_EMPTY_BODY = YES;
231 | CLANG_WARN_ENUM_CONVERSION = YES;
232 | CLANG_WARN_INT_CONVERSION = YES;
233 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
234 | CLANG_WARN_UNREACHABLE_CODE = YES;
235 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
236 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
237 | COPY_PHASE_STRIP = NO;
238 | CURRENT_PROJECT_VERSION = 1;
239 | DEBUG_INFORMATION_FORMAT = dwarf;
240 | ENABLE_STRICT_OBJC_MSGSEND = YES;
241 | ENABLE_TESTABILITY = YES;
242 | GCC_C_LANGUAGE_STANDARD = gnu99;
243 | GCC_DYNAMIC_NO_PIC = NO;
244 | GCC_NO_COMMON_BLOCKS = YES;
245 | GCC_OPTIMIZATION_LEVEL = 0;
246 | GCC_PREPROCESSOR_DEFINITIONS = (
247 | "DEBUG=1",
248 | "$(inherited)",
249 | );
250 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
251 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
252 | GCC_WARN_UNDECLARED_SELECTOR = YES;
253 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
254 | GCC_WARN_UNUSED_FUNCTION = YES;
255 | GCC_WARN_UNUSED_VARIABLE = YES;
256 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
257 | MTL_ENABLE_DEBUG_INFO = YES;
258 | ONLY_ACTIVE_ARCH = YES;
259 | SDKROOT = iphoneos;
260 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
261 | TARGETED_DEVICE_FAMILY = "1,2";
262 | VERSIONING_SYSTEM = "apple-generic";
263 | VERSION_INFO_PREFIX = "";
264 | };
265 | name = Debug;
266 | };
267 | 94ABF6CF1B9BB366009A22E3 /* Release */ = {
268 | isa = XCBuildConfiguration;
269 | buildSettings = {
270 | ALWAYS_SEARCH_USER_PATHS = NO;
271 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
272 | CLANG_CXX_LIBRARY = "libc++";
273 | CLANG_ENABLE_MODULES = YES;
274 | CLANG_ENABLE_OBJC_ARC = YES;
275 | CLANG_WARN_BOOL_CONVERSION = YES;
276 | CLANG_WARN_CONSTANT_CONVERSION = YES;
277 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
278 | CLANG_WARN_EMPTY_BODY = YES;
279 | CLANG_WARN_ENUM_CONVERSION = YES;
280 | CLANG_WARN_INT_CONVERSION = YES;
281 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
282 | CLANG_WARN_UNREACHABLE_CODE = YES;
283 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
284 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
285 | COPY_PHASE_STRIP = NO;
286 | CURRENT_PROJECT_VERSION = 1;
287 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
288 | ENABLE_NS_ASSERTIONS = NO;
289 | ENABLE_STRICT_OBJC_MSGSEND = YES;
290 | GCC_C_LANGUAGE_STANDARD = gnu99;
291 | GCC_NO_COMMON_BLOCKS = YES;
292 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
293 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
294 | GCC_WARN_UNDECLARED_SELECTOR = YES;
295 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
296 | GCC_WARN_UNUSED_FUNCTION = YES;
297 | GCC_WARN_UNUSED_VARIABLE = YES;
298 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
299 | MTL_ENABLE_DEBUG_INFO = NO;
300 | SDKROOT = iphoneos;
301 | TARGETED_DEVICE_FAMILY = "1,2";
302 | VALIDATE_PRODUCT = YES;
303 | VERSIONING_SYSTEM = "apple-generic";
304 | VERSION_INFO_PREFIX = "";
305 | };
306 | name = Release;
307 | };
308 | 94ABF6E01B9BB5F9009A22E3 /* Debug */ = {
309 | isa = XCBuildConfiguration;
310 | buildSettings = {
311 | DEFINES_MODULE = YES;
312 | DYLIB_COMPATIBILITY_VERSION = 1;
313 | DYLIB_CURRENT_VERSION = 1;
314 | DYLIB_INSTALL_NAME_BASE = "@rpath";
315 | INFOPLIST_FILE = "cURLLook-iOS/Info.plist";
316 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
317 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
318 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
319 | PRODUCT_BUNDLE_IDENTIFIER = "net.dduan.cURLLook-iOS";
320 | PRODUCT_NAME = cURLLook;
321 | SKIP_INSTALL = YES;
322 | };
323 | name = Debug;
324 | };
325 | 94ABF6E11B9BB5F9009A22E3 /* Release */ = {
326 | isa = XCBuildConfiguration;
327 | buildSettings = {
328 | DEFINES_MODULE = YES;
329 | DYLIB_COMPATIBILITY_VERSION = 1;
330 | DYLIB_CURRENT_VERSION = 1;
331 | DYLIB_INSTALL_NAME_BASE = "@rpath";
332 | INFOPLIST_FILE = "cURLLook-iOS/Info.plist";
333 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
334 | IPHONEOS_DEPLOYMENT_TARGET = 8.0;
335 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
336 | PRODUCT_BUNDLE_IDENTIFIER = "net.dduan.cURLLook-iOS";
337 | PRODUCT_NAME = cURLLook;
338 | SKIP_INSTALL = YES;
339 | };
340 | name = Release;
341 | };
342 | 94ABF6ED1B9BB623009A22E3 /* Debug */ = {
343 | isa = XCBuildConfiguration;
344 | buildSettings = {
345 | COMBINE_HIDPI_IMAGES = YES;
346 | DEFINES_MODULE = YES;
347 | DYLIB_COMPATIBILITY_VERSION = 1;
348 | DYLIB_CURRENT_VERSION = 1;
349 | DYLIB_INSTALL_NAME_BASE = "@rpath";
350 | FRAMEWORK_VERSION = A;
351 | INFOPLIST_FILE = "cURLLook-OSX/Info.plist";
352 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
353 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
354 | MACOSX_DEPLOYMENT_TARGET = 10.10;
355 | PRODUCT_BUNDLE_IDENTIFIER = "net.dduan.cURLLook-OSX";
356 | PRODUCT_NAME = cURLLook;
357 | SDKROOT = macosx;
358 | SKIP_INSTALL = YES;
359 | };
360 | name = Debug;
361 | };
362 | 94ABF6EE1B9BB623009A22E3 /* Release */ = {
363 | isa = XCBuildConfiguration;
364 | buildSettings = {
365 | COMBINE_HIDPI_IMAGES = YES;
366 | DEFINES_MODULE = YES;
367 | DYLIB_COMPATIBILITY_VERSION = 1;
368 | DYLIB_CURRENT_VERSION = 1;
369 | DYLIB_INSTALL_NAME_BASE = "@rpath";
370 | FRAMEWORK_VERSION = A;
371 | INFOPLIST_FILE = "cURLLook-OSX/Info.plist";
372 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
373 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
374 | MACOSX_DEPLOYMENT_TARGET = 10.10;
375 | PRODUCT_BUNDLE_IDENTIFIER = "net.dduan.cURLLook-OSX";
376 | PRODUCT_NAME = cURLLook;
377 | SDKROOT = macosx;
378 | SKIP_INSTALL = YES;
379 | };
380 | name = Release;
381 | };
382 | /* End XCBuildConfiguration section */
383 |
384 | /* Begin XCConfigurationList section */
385 | 94ABF6C21B9BB366009A22E3 /* Build configuration list for PBXProject "cURLLook" */ = {
386 | isa = XCConfigurationList;
387 | buildConfigurations = (
388 | 94ABF6CE1B9BB366009A22E3 /* Debug */,
389 | 94ABF6CF1B9BB366009A22E3 /* Release */,
390 | );
391 | defaultConfigurationIsVisible = 0;
392 | defaultConfigurationName = Release;
393 | };
394 | 94ABF6DF1B9BB5F9009A22E3 /* Build configuration list for PBXNativeTarget "cURLLook-iOS" */ = {
395 | isa = XCConfigurationList;
396 | buildConfigurations = (
397 | 94ABF6E01B9BB5F9009A22E3 /* Debug */,
398 | 94ABF6E11B9BB5F9009A22E3 /* Release */,
399 | );
400 | defaultConfigurationIsVisible = 0;
401 | defaultConfigurationName = Release;
402 | };
403 | 94ABF6EC1B9BB623009A22E3 /* Build configuration list for PBXNativeTarget "cURLLook-OSX" */ = {
404 | isa = XCConfigurationList;
405 | buildConfigurations = (
406 | 94ABF6ED1B9BB623009A22E3 /* Debug */,
407 | 94ABF6EE1B9BB623009A22E3 /* Release */,
408 | );
409 | defaultConfigurationIsVisible = 0;
410 | defaultConfigurationName = Release;
411 | };
412 | /* End XCConfigurationList section */
413 | };
414 | rootObject = 94ABF6BF1B9BB366009A22E3 /* Project object */;
415 | }
416 |
--------------------------------------------------------------------------------
/cURLLook.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/cURLLook.xcodeproj/xcshareddata/xcschemes/cURLLook-OSX.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
34 |
35 |
45 |
46 |
52 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
70 |
71 |
72 |
73 |
75 |
76 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/cURLLook.xcodeproj/xcshareddata/xcschemes/cURLLook-iOS.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
34 |
35 |
45 |
46 |
52 |
53 |
54 |
55 |
56 |
57 |
63 |
64 |
70 |
71 |
72 |
73 |
75 |
76 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/cURLLook/NSURLRequestCURLRepresentation.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NSURLRequestCURLRepresentation.swift
3 | // cURLLook
4 | //
5 | // Created by Daniel Duan on 9/5/15.
6 | //
7 | //
8 |
9 | import Foundation
10 |
11 | extension NSURLRequest {
12 | /**
13 | Convenience property, the value of calling `cURLRepresentation()` with no arguments.
14 | */
15 | public var cURLString: String {
16 | get {
17 | return cURLRepresentation()
18 | }
19 | }
20 |
21 | /**
22 | cURL (http://http://curl.haxx.se) is a commandline tool that makes network requests. This method serializes a `NSURLRequest` to a cURL
23 | command that performs the same HTTP request.
24 |
25 | - Parameter session: *optional* the `NSURLSession` this NSURLRequest is being used with. Extra information from the session such as
26 | cookies and credentials may be included in the result.
27 | - Parameter credential: *optional* the credential to include in the result. The value of `session?.configuration.URLCredentialStorage`,
28 | when present, would override this argument.
29 |
30 | - Returns: a string whose value is a cURL command that would perform the same HTTP request this object represents.
31 | */
32 | public func cURLRepresentation(withURLSession session: NSURLSession? = nil, credential: NSURLCredential? = nil) -> String {
33 | var components = ["curl -i"]
34 |
35 | let URL = self.URL
36 |
37 | if let HTTPMethod = self.HTTPMethod where HTTPMethod != "GET" {
38 | components.append("-X \(HTTPMethod)")
39 | }
40 |
41 | if let credentialStorage = session?.configuration.URLCredentialStorage {
42 | let protectionSpace = NSURLProtectionSpace(
43 | host: URL!.host!,
44 | port: URL!.port?.integerValue ?? 0,
45 | protocol: URL!.scheme,
46 | realm: URL!.host!,
47 | authenticationMethod: NSURLAuthenticationMethodHTTPBasic
48 | )
49 |
50 | if let credentials = credentialStorage.credentialsForProtectionSpace(protectionSpace)?.values {
51 | for credential in credentials {
52 | components.append("-u \(credential.user!):\(credential.password!)")
53 | }
54 | } else {
55 | if credential != nil {
56 | components.append("-u \(credential!.user!):\(credential!.password!)")
57 | }
58 | }
59 | }
60 |
61 | if session != nil && session!.configuration.HTTPShouldSetCookies {
62 | if let
63 | cookieStorage = session!.configuration.HTTPCookieStorage,
64 | cookies = cookieStorage.cookiesForURL(URL!) where !cookies.isEmpty
65 | {
66 | let string = cookies.reduce("") { $0 + "\($1.name)=\($1.value ?? String());" }
67 | components.append("-b \"\(string.substringToIndex(string.endIndex.predecessor()))\"")
68 | }
69 | }
70 |
71 | if let headerFields = self.allHTTPHeaderFields {
72 | for (field, value) in headerFields {
73 | switch field {
74 | case "Cookie":
75 | continue
76 | default:
77 | components.append("-H \"\(field): \(value)\"")
78 | }
79 | }
80 | }
81 |
82 | if let additionalHeaders = session?.configuration.HTTPAdditionalHeaders {
83 | for (field, value) in additionalHeaders {
84 | switch field {
85 | case "Cookie":
86 | continue
87 | default:
88 | components.append("-H \"\(field): \(value)\"")
89 | }
90 | }
91 | }
92 |
93 | if let
94 | HTTPBodyData = self.HTTPBody,
95 | HTTPBody = NSString(data: HTTPBodyData, encoding: NSUTF8StringEncoding)
96 | {
97 | let escapedBody = HTTPBody.stringByReplacingOccurrencesOfString("\"", withString: "\\\"")
98 | components.append("-d \"\(escapedBody)\"")
99 | }
100 |
101 | components.append("\"\(URL!.absoluteString)\"")
102 |
103 | return components.joinWithSeparator(" \\\n\t")
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------