Skip to content
This repository was archived by the owner on Dec 10, 2024. It is now read-only.

Commit fdb6dfc

Browse files
committed
Merge branch 'swift3'
2 parents 7be0eb1 + f7d4c02 commit fdb6dfc

File tree

21 files changed

+1912
-1995
lines changed

21 files changed

+1912
-1995
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +0,0 @@
1-
[submodule "Externals/Quick"]
2-
path = Externals/Quick
3-
url = https://github.com/Quick/Quick.git

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
language: objective-c
2-
osx_image: xcode7.1
2+
osx_image: xcode8
33
before_install:
44
- git submodule update --init --recursive
55
- gem install cocoapods --no-rdoc --no-ri --no-document --quiet

Docs/QuickStart.playground/Contents.swift

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ Just.get("http://httpbin.org/get", params:["page": 3])
4242

4343
var r = Just.get("http://httpbin.org/get", params:["page": 3])
4444
// … "r" becomes available here
45-
4645
//: However, Just doesn't force you to choose. The same request can be made
4746
//: asynchronously like this
4847

@@ -98,7 +97,7 @@ r.headers["Content-Length"] == r.headers["cOnTeNt-LeNgTh"] // true
9897
//: The original request is preserved as a *NSURLRequest*:
9998

10099
r.request // NSURLRequest sent
101-
r.request?.HTTPMethod // GET
100+
r.request?.httpMethod // GET
102101

103102
//: When things aren't going so well:
104103
let erronous = Just.get("http://httpbin.org/does/not/exist") // oops
@@ -145,23 +144,20 @@ Just.get("http://httpbin.org/status/302", allowRedirects:false).isPermanentRedir
145144

146145
import Foundation
147146

148-
149-
150-
let elonPhotoURL = NSBundle.mainBundle().URLForResource("elon", withExtension: "jpg")! // assume the file exist
151-
let uploadResult = Just.post("http://httpbin.org/post", files:["elon":.URL(elonPhotoURL, nil)]) // <== that's it
147+
let elonPhotoURL = Bundle.main.url(forResource: "elon", withExtension: "jpg")!
148+
let uploadResult = Just.post("http://httpbin.org/post", files:["elon": .url(elonPhotoURL, nil)]) // <== that's it
152149
print(uploadResult.text ?? "")
153150

154151
//: Here a file is specified with an NSURL. Alternatively, a file can be a NSData or just a string. Although in both cases, a filename is needed.
155-
156-
let someData = "Marco".dataUsingEncoding(NSUTF8StringEncoding)! // this shouldn't fail
152+
let someData = "Marco".data(using: String.Encoding.utf8)! // this shouldn't fail
157153

158154
if let text = Just.post(
159155
"http://httpbin.org/post",
160156
files:[
161-
"a":.Data("marco.text", someData, nil), // file #1, an NSData
162-
"b":.Text("polo.txt", "Polo", nil) // file #2, a String
157+
"a":.data("marco.text", someData, nil), // file #1, an NSData
158+
"b":.text("polo.txt", "Polo", nil) // file #2, a String
163159
]
164-
).text {
160+
).text {
165161
print(text)
166162
}
167163

@@ -175,8 +171,8 @@ if let text = Just.post(
175171
if let json = Just.post(
176172
"http://httpbin.org/post",
177173
data:["lastName":"Musk"],
178-
files:["elon":.URL(elonPhotoURL, nil)]
179-
).json as? [String:AnyObject] {
174+
files:["elon":.url(elonPhotoURL, nil)]
175+
).json as? [String:AnyObject] {
180176
print(json["form"] ?? [:]) // lastName:Musk
181177
print(json["files"] ?? [:]) // elon
182178
}
@@ -227,16 +223,17 @@ Just.get("http://httpbin.org/delay/5", timeout:0.2).reason
227223
//: When dealing with large files, you may be interested in knowing the progress
228224
//: of their uploading or downloading. You can do that by supplynig a call back
229225
//: to the parameter **asyncProgressHandler**.
226+
230227
Just.post(
231228
"http://httpbin.org/post",
232-
files:["large file":.Text("or", "pretend this is a large file", nil)],
233-
asyncProgressHandler: {(p) in
229+
files:["large file":.text("or", "pretend this is a large file", nil)],
230+
asyncProgressHandler: { p in
234231
p.type // either .Upload or .Download
235232
p.bytesProcessed
236233
p.bytesExpectedToProcess
237234
p.percent
238235
}
239-
) { (r) in
236+
) { r in
240237
// finished
241238
}
242239

@@ -253,14 +250,15 @@ Just.post(
253250
//: To change these settings, one must create a separate instance of Just instead of using the
254251
//: default one. Doing so opens up the oppurtunity to customize NSURLSession in
255252
//: powerful ways. A `JustSessionDefaults` can be used to provide some customization points:
253+
//
256254

257255
let myJustDefaults = JustSessionDefaults(
258-
JSONReadingOptions: .MutableContainers, // NSJSONSerialization reading options
259-
JSONWritingOptions: .PrettyPrinted, // NSJSONSerialization writing options
256+
JSONReadingOptions: .mutableContainers, // NSJSONSerialization reading options
257+
JSONWritingOptions: .prettyPrinted, // NSJSONSerialization writing options
260258
headers: ["OH":"MY"], // headers to include in every request
261259
multipartBoundary: "Ju5tH77P15Aw350m3", // multipart post request boundaries
262-
credentialPersistence: .None, // NSURLCredential persistence options
263-
encoding: NSUTF8StringEncoding // en(de)coding for HTTP body
260+
credentialPersistence: .none, // NSURLCredential persistence options
261+
encoding: String.Encoding.utf8 // en(de)coding for HTTP body
264262
)
265263

266264
//: Just initializer accepts an `defaults` argement. Use it like this:

Docs/QuickStart.playground/playground.xcworkspace/contents.xcworkspacedata

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Docs/QuickStart.playground/timeline.xctimeline

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,30 @@
33
version = "3.0">
44
<TimelineItems>
55
<LoggerValueHistoryTimelineItem
6-
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=0&amp;EndingColumnNumber=20&amp;EndingLineNumber=183&amp;StartingColumnNumber=9&amp;StartingLineNumber=183&amp;Timestamp=469923798.881402"
6+
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=10086&amp;EndingColumnNumber=20&amp;EndingLineNumber=446&amp;StartingColumnNumber=9&amp;StartingLineNumber=446&amp;Timestamp=495267299.573989"
77
selectedRepresentationIndex = "0"
88
shouldTrackSuperviewWidth = "NO">
99
</LoggerValueHistoryTimelineItem>
1010
<LoggerValueHistoryTimelineItem
11-
documentLocation = "#CharacterRangeLen=6&amp;CharacterRangeLoc=2853&amp;EndingColumnNumber=7&amp;EndingLineNumber=81&amp;StartingColumnNumber=1&amp;StartingLineNumber=81&amp;Timestamp=462872716.632806"
11+
documentLocation = "#CharacterRangeLen=6&amp;CharacterRangeLoc=12841&amp;EndingColumnNumber=7&amp;EndingLineNumber=344&amp;StartingColumnNumber=1&amp;StartingLineNumber=344&amp;Timestamp=495267299.574109"
1212
selectedRepresentationIndex = "0"
1313
shouldTrackSuperviewWidth = "NO">
1414
</LoggerValueHistoryTimelineItem>
1515
<LoggerValueHistoryTimelineItem
16-
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=7103&amp;EndingColumnNumber=17&amp;EndingLineNumber=196&amp;StartingColumnNumber=1&amp;StartingLineNumber=195&amp;Timestamp=469924029.457252"
16+
documentLocation = "#CharacterRangeLen=0&amp;CharacterRangeLoc=17091&amp;EndingColumnNumber=17&amp;EndingLineNumber=459&amp;StartingColumnNumber=1&amp;StartingLineNumber=458&amp;Timestamp=495267299.574201"
1717
selectedRepresentationIndex = "0"
1818
shouldTrackSuperviewWidth = "NO">
1919
</LoggerValueHistoryTimelineItem>
2020
<LoggerValueHistoryTimelineItem
21-
documentLocation = "#CharacterRangeLen=78&amp;CharacterRangeLoc=4470&amp;EndingColumnNumber=79&amp;EndingLineNumber=159&amp;StartingColumnNumber=1&amp;StartingLineNumber=159&amp;Timestamp=469924013.688527"
21+
documentLocation = "#CharacterRangeLen=78&amp;CharacterRangeLoc=14458&amp;EndingColumnNumber=79&amp;EndingLineNumber=422&amp;StartingColumnNumber=1&amp;StartingLineNumber=422&amp;Timestamp=495267299.57429"
2222
lockedSize = "{1048, 304}"
2323
selectedRepresentationIndex = "0"
2424
shouldTrackSuperviewWidth = "NO">
2525
</LoggerValueHistoryTimelineItem>
26+
<LoggerValueHistoryTimelineItem
27+
documentLocation = "#CharacterRangeLen=1&amp;CharacterRangeLoc=20107&amp;EndingColumnNumber=72&amp;EndingLineNumber=533&amp;StartingColumnNumber=1&amp;StartingLineNumber=533&amp;Timestamp=495267299.574418"
28+
selectedRepresentationIndex = "0"
29+
shouldTrackSuperviewWidth = "NO">
30+
</LoggerValueHistoryTimelineItem>
2631
</TimelineItems>
2732
</Timeline>

Docs/QuickStart.zip

8.09 KB
Binary file not shown.

Externals/Quick

Lines changed: 0 additions & 1 deletion
This file was deleted.

Just.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Pod::Spec.new do |s|
33

44
s.name = "Just"
5-
s.version = "0.4.8"
5+
s.version = "0.5.0"
66
s.summary = "Swift HTTP for Humans"
77

88
s.description = <<-DESC

0 commit comments

Comments
 (0)