Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Swift 5 #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:4.1
// swift-tools-version:5.1
//
// Package.swift
// PerfectHTTP
Expand Down Expand Up @@ -27,8 +27,8 @@ let package = Package(
.library(name: "PerfectHTTP", targets: ["PerfectHTTP"])
],
dependencies: [
.package(url: "https://github.com/PerfectlySoft/PerfectLib.git", from: "3.0.0"),
.package(url: "https://github.com/PerfectlySoft/Perfect-Net.git", from: "3.0.0"),
.package(url: "https://github.com/PerfectlySoft/PerfectLib.git", from: "4.0.0"),
.package(url: "https://github.com/PerfectlySoft/Perfect-Net.git", from: "4.0.0"),
.package(url: "https://github.com/PerfectlySoft/Perfect-LinuxBridge.git", from: "3.0.0")
],
targets: [
Expand All @@ -39,12 +39,15 @@ let package = Package(
#else
let package = Package(
name: "PerfectHTTP",
platforms: [
.macOS(.v10_15)
],
products: [
.library(name: "PerfectHTTP", targets: ["PerfectHTTP"])
],
dependencies: [
.package(url: "https://github.com/PerfectlySoft/PerfectLib.git", from: "3.0.0"),
.package(url: "https://github.com/PerfectlySoft/Perfect-Net.git", from: "3.0.0")
.package(url: "https://github.com/PerfectlySoft/PerfectLib.git", from: "4.0.0"),
.package(url: "https://github.com/PerfectlySoft/Perfect-Net.git", from: "4.0.0")
], targets: [
.target(name: "PerfectHTTP", dependencies: ["PerfectLib", "PerfectNet"]),
.testTarget(name: "PerfectHTTPTests", dependencies: ["PerfectHTTP", "PerfectNet"])
Expand Down
2 changes: 1 addition & 1 deletion Sources/PerfectHTTP/HTTPRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import PerfectNet

/// An HTTP based request object.
/// Contains all HTTP header and content data submitted by the client.
public protocol HTTPRequest: class {
public protocol HTTPRequest: AnyObject {
/// The HTTP request method.
var method: HTTPMethod { get set }
/// The request path.
Expand Down
2 changes: 1 addition & 1 deletion Sources/PerfectHTTP/HTTPResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public struct HTTPCookie {

/// An HTTP based response object.
/// Contains all header and body data which will be delivered to the client.
public protocol HTTPResponse: class {
public protocol HTTPResponse: AnyObject {
/// The request object which instigated this response.
var request: HTTPRequest { get }
/// The HTTP response status.
Expand Down
2 changes: 1 addition & 1 deletion Sources/PerfectHTTP/MimeReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ public final class MimeReader {
}
// write as much data as we reasonably can
var writeEnd = position
let qPtr = UnsafePointer<UInt8>(byts)
let qPtr = byts.withUnsafeBufferPointer { $0.baseAddress! }
while writeEnd < end {

if qPtr[writeEnd] == mime_cr {
Expand Down
6 changes: 3 additions & 3 deletions Tests/PerfectHTTPTests/PerfectHTTPTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ class PerfectHTTPTests: XCTestCase {
response.handlers = handlers
response.next()
XCTAssertEqual(response.header(.contentType), "application/json")
let decodeCheck = try? JSONDecoder().decode(RequestResponse.self, from: Data(bytes: response.bodyBytes))
let decodeCheck = try? JSONDecoder().decode(RequestResponse.self, from: Data(response.bodyBytes))
XCTAssertNotNil(decodeCheck)
}
do {
Expand All @@ -627,7 +627,7 @@ class PerfectHTTPTests: XCTestCase {
response.handlers = handlers
response.next()
XCTAssertEqual(response.header(.contentType), "foo/bar")
let decodeCheck = try? JSONDecoder().decode(RequestResponse.self, from: Data(bytes: response.bodyBytes))
let decodeCheck = try? JSONDecoder().decode(RequestResponse.self, from: Data(response.bodyBytes))
XCTAssertNotNil(decodeCheck)
}
do {
Expand Down Expand Up @@ -686,7 +686,7 @@ class PerfectHTTPTests: XCTestCase {
self.waitForExpectations(timeout: 10) { _ in }

XCTAssertEqual(response.header(.contentType), "application/json")
let decodeCheck = try? JSONDecoder().decode(Body.self, from: Data(bytes: response.bodyBytes))
let decodeCheck = try? JSONDecoder().decode(Body.self, from: Data(response.bodyBytes))
XCTAssertNotNil(decodeCheck)
}

Expand Down