Skip to content

Commit

Permalink
Merge pull request #38 from pocket7878/avoid-parsing-when-status-is-n…
Browse files Browse the repository at this point in the history
…o-content

Avoid parsing when status is 204.
  • Loading branch information
ishkawa committed May 23, 2015
2 parents 648e9a5 + 48f37ef commit a5c01f7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion APIKit/API.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public class API {
return .failure(error)
}
}

dispatch_async(mainQueue) { handler(mappedResponse) }
}

Expand Down
3 changes: 3 additions & 0 deletions APIKit/ResponseBodyParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public enum ResponseBodyParser {
public func parseData(data: NSData) -> Result<AnyObject, NSError> {
switch self {
case .JSON(let readingOptions):
if data.length == 0 {
return .success([:])
}
return try { error in
return NSJSONSerialization.JSONObjectWithData(data, options: readingOptions, error: error)
}
Expand Down
4 changes: 2 additions & 2 deletions Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
github "antitypical/Assertions" "1.1"
github "robrix/Box" "1.2.2"
github "AliSoftware/OHHTTPStubs" "4.0.1"
github "antitypical/Result" "0.4.1"
github "AliSoftware/OHHTTPStubs" "4.0.2"
github "antitypical/Result" "0.4.3"

0 comments on commit a5c01f7

Please sign in to comment.