Skip to content

Instantly share code, notes, and snippets.

@chockenberry
Created May 23, 2023 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chockenberry/658fb5b5b643b631e42d68ba4c64c156 to your computer and use it in GitHub Desktop.
Save chockenberry/658fb5b5b643b631e42d68ba4c64c156 to your computer and use it in GitHub Desktop.
URLSession with SSH and HTTP
import Foundation
Task<Void,Never> {
do {
if let url = URL(string: "http://localhost:22") {
let (_, response) = try await URLSession.shared.data(from: url)
if let response = response as? HTTPURLResponse {
print(response.statusCode)
}
else {
print(response)
}
}
}
catch {
print(error)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment