-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump HexaviileFramework version to 1.0.0-rc.1
- Loading branch information
Showing
14 changed files
with
133 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// HTTPClient.swift | ||
// CNIOAtomics | ||
// | ||
// Created by Yuki Takei on 2018/12/12. | ||
// | ||
|
||
import Foundation | ||
import Dispatch | ||
|
||
struct HTTPClient { | ||
func send(request: URLRequest) throws -> (HTTPURLResponse, Data) { | ||
var _error: Error? | ||
var _data: Data? | ||
var _response: HTTPURLResponse? | ||
let semaphore = DispatchSemaphore(value: 0) | ||
let task = URLSession.shared.dataTask(with: request) { data, response, error in | ||
_error = error | ||
_data = data | ||
_response = response as? HTTPURLResponse | ||
semaphore.signal() | ||
} | ||
|
||
task.resume() | ||
|
||
semaphore.wait() | ||
|
||
if let error = _error { | ||
throw error | ||
} | ||
|
||
return (_response!, _data ?? Data()) | ||
} | ||
|
||
func send(url: URL) throws -> (HTTPURLResponse, Data) { | ||
return try self.send(request: URLRequest(url: url)) | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.