Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit a3dc191
Author: Jon Shier <jon@jonshier.com>
Date:   Sat Nov 24 17:35:17 2018 -0500

    Add additional tests.

commit ae8fde4
Merge: 34f3668 ea48749
Author: Jon Shier <jon@jonshier.com>
Date:   Sat Nov 24 16:43:12 2018 -0500

    Merge remote-tracking branch 'origin/feature/httpheaders' into feature/encodable-requests

    # Conflicts:
    #	Source/AFError.swift

commit ea48749
Author: Jon Shier <jon@jonshier.com>
Date:   Sat Nov 24 16:25:48 2018 -0500

    Call add instead of update.

commit 2d73562
Author: Jon Shier <jon@jonshier.com>
Date:   Sat Nov 24 16:24:48 2018 -0500

    Add add methods to HTTPHeaders, whitespace cleanup.

commit f2bf395
Merge: 410a2e3 7a73af6
Author: Jon Shier <jon@jonshier.com>
Date:   Wed Nov 21 19:45:38 2018 -0500

    Merge remote-tracking branch 'origin/alamofire5' into feature/httpheaders

    # Conflicts:
    #	Tests/SessionManagerTests.swift

commit 410a2e3
Author: Jon Shier <jon@jonshier.com>
Date:   Wed Nov 21 19:44:15 2018 -0500

    Squashed commit of the following:

    commit 7a73af6
    Author: Jon Shier <jon@jonshier.com>
    Date:   Wed Nov 21 19:39:20 2018 -0500

        Async RequestAdapter (#2628)

        * Work towards server trust enhancements.

        * Refactor the rewrite! (#2585)

        * Refactor request storage out of SessionDelegate.

        * Continue development.

        * Rename SessionManager -> Session, update environment.

        * Rename global Alamofire enum to AF, to avoid collision.

        * Sort project.

        * Whitespace cleanup.

        * Reimplement module changes from bad rebase.

        * Finalize errors, refactor testing.

        * Standardize self-signed support, add error descriptions.

        * Remove per-target setting.

        * Make RequestAdapter async.

    commit ccfb96a
    Author: Jon Shier <jon@jonshier.com>
    Date:   Wed Nov 21 19:32:04 2018 -0500

        Alamofire 5: Server Trust Errors (#2608)

        * Work towards server trust enhancements.

        * Refactor the rewrite! (#2585)

        * Refactor request storage out of SessionDelegate.

        * Continue development.

        * Rename SessionManager -> Session, update environment.

        * Rename global Alamofire enum to AF, to avoid collision.

        * Sort project.

        * Whitespace cleanup.

        * Reimplement module changes from bad rebase.

        * Finalize errors, refactor testing.

        * Standardize self-signed support, add error descriptions.

        * Remove per-target setting.

        * Refactor evaluation API, DRY up a little bit.

        * Update convienience property.

        * Add comment for public `Error` API.

commit 7a73af6
Author: Jon Shier <jon@jonshier.com>
Date:   Wed Nov 21 19:39:20 2018 -0500

    Async RequestAdapter (#2628)

    * Work towards server trust enhancements.

    * Refactor the rewrite! (#2585)

    * Refactor request storage out of SessionDelegate.

    * Continue development.

    * Rename SessionManager -> Session, update environment.

    * Rename global Alamofire enum to AF, to avoid collision.

    * Sort project.

    * Whitespace cleanup.

    * Reimplement module changes from bad rebase.

    * Finalize errors, refactor testing.

    * Standardize self-signed support, add error descriptions.

    * Remove per-target setting.

    * Make RequestAdapter async.

commit ccfb96a
Author: Jon Shier <jon@jonshier.com>
Date:   Wed Nov 21 19:32:04 2018 -0500

    Alamofire 5: Server Trust Errors (#2608)

    * Work towards server trust enhancements.

    * Refactor the rewrite! (#2585)

    * Refactor request storage out of SessionDelegate.

    * Continue development.

    * Rename SessionManager -> Session, update environment.

    * Rename global Alamofire enum to AF, to avoid collision.

    * Sort project.

    * Whitespace cleanup.

    * Reimplement module changes from bad rebase.

    * Finalize errors, refactor testing.

    * Standardize self-signed support, add error descriptions.

    * Remove per-target setting.

    * Refactor evaluation API, DRY up a little bit.

    * Update convienience property.

    * Add comment for public `Error` API.

commit 34f3668
Author: Jon Shier <jon@jonshier.com>
Date:   Wed Nov 21 19:26:32 2018 -0500

    Add additional tests.

commit ba2e15c
Author: Jon Shier <jon@jonshier.com>
Date:   Wed Nov 21 18:56:14 2018 -0500

    Update comments, DRY up single value container.

commit 38d764b
Author: Jon Shier <jon@jonshier.com>
Date:   Wed Nov 21 18:36:01 2018 -0500

    Whitespace cleanup.

commit b0cf0c5
Merge: 22ccd91 4adae8c
Author: Jon Shier <jon@jonshier.com>
Date:   Wed Nov 21 18:35:16 2018 -0500

    Merge remote-tracking branch 'origin/feature/httpheaders' into feature/encodable-requests

commit 4adae8c
Author: Jon Shier <jon@jonshier.com>
Date:   Wed Nov 21 18:30:59 2018 -0500

    Whitespace cleanup.

commit aaa3e6a
Author: Jon Shier <jon@jonshier.com>
Date:   Wed Nov 21 18:29:30 2018 -0500

    Updates for review.

commit 22ccd91
Author: Christian Noon <christian.noon@gmail.com>
Date:   Wed Nov 21 14:20:08 2018 -0800

    Enabled code coverage for iOS, macOS, and tvOS framework schemes (#2645)
  • Loading branch information
jshier committed Nov 24, 2018
1 parent f265846 commit 6248e8d
Show file tree
Hide file tree
Showing 19 changed files with 462 additions and 235 deletions.
16 changes: 8 additions & 8 deletions Alamofire.xcodeproj/project.pbxproj
Expand Up @@ -33,9 +33,9 @@
3107EA3F20A1267C00445260 /* SessionDelegateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C9DCE771CB1BCE2003E6463 /* SessionDelegateTests.swift */; };
3107EA4020A1267C00445260 /* SessionDelegateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C9DCE771CB1BCE2003E6463 /* SessionDelegateTests.swift */; };
3107EA4120A1267D00445260 /* SessionDelegateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4C9DCE771CB1BCE2003E6463 /* SessionDelegateTests.swift */; };
3111CE8420A7636E008315E2 /* SessionManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8D1C6F419D52968002E74FE /* SessionManagerTests.swift */; };
3111CE8520A7636F008315E2 /* SessionManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8D1C6F419D52968002E74FE /* SessionManagerTests.swift */; };
3111CE8620A76370008315E2 /* SessionManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8D1C6F419D52968002E74FE /* SessionManagerTests.swift */; };
3111CE8420A7636E008315E2 /* SessionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8D1C6F419D52968002E74FE /* SessionTests.swift */; };
3111CE8520A7636F008315E2 /* SessionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8D1C6F419D52968002E74FE /* SessionTests.swift */; };
3111CE8620A76370008315E2 /* SessionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8D1C6F419D52968002E74FE /* SessionTests.swift */; };
3111CE8820A77843008315E2 /* EventMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3111CE8720A77843008315E2 /* EventMonitor.swift */; };
3111CE8920A77944008315E2 /* EventMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3111CE8720A77843008315E2 /* EventMonitor.swift */; };
3111CE8A20A77945008315E2 /* EventMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3111CE8720A77843008315E2 /* EventMonitor.swift */; };
Expand Down Expand Up @@ -445,7 +445,7 @@
F86AEFE51AE6A282007D9C76 /* TLSEvaluationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TLSEvaluationTests.swift; sourceTree = "<group>"; };
F897FF4019AA800700AB5182 /* Alamofire.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Alamofire.swift; sourceTree = "<group>"; };
F8AE910119D28DCC0078C7B2 /* ValidationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ValidationTests.swift; sourceTree = "<group>"; };
F8D1C6F419D52968002E74FE /* SessionManagerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SessionManagerTests.swift; sourceTree = "<group>"; };
F8D1C6F419D52968002E74FE /* SessionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SessionTests.swift; sourceTree = "<group>"; };
F8E6024419CB46A800A3E7F1 /* AuthenticationTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthenticationTests.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

Expand Down Expand Up @@ -516,7 +516,7 @@
F8111E5E19A9674D0040E7D1 /* ResponseTests.swift */,
4CA028C41B7466C500C84163 /* ResultTests.swift */,
4C9DCE771CB1BCE2003E6463 /* SessionDelegateTests.swift */,
F8D1C6F419D52968002E74FE /* SessionManagerTests.swift */,
F8D1C6F419D52968002E74FE /* SessionTests.swift */,
F8111E5F19A9674D0040E7D1 /* UploadTests.swift */,
);
name = Core;
Expand Down Expand Up @@ -1312,7 +1312,7 @@
4CF627141BA7CC240011A099 /* BaseTestCase.swift in Sources */,
31727424218BB9A50039FFCC /* HTTPBin.swift in Sources */,
31EBD9C320D1D89D00D1FF34 /* ValidationTests.swift in Sources */,
3111CE8620A76370008315E2 /* SessionManagerTests.swift in Sources */,
3111CE8620A76370008315E2 /* SessionTests.swift in Sources */,
31C2B0F220B271380089BA7C /* TLSEvaluationTests.swift in Sources */,
3111CE9D20A7EC58008315E2 /* URLProtocolTests.swift in Sources */,
317A6A7820B2208000A9FEC5 /* DownloadTests.swift in Sources */,
Expand Down Expand Up @@ -1445,7 +1445,7 @@
4C256A531B096C770065714F /* BaseTestCase.swift in Sources */,
31727422218BB9A50039FFCC /* HTTPBin.swift in Sources */,
31EBD9C120D1D89C00D1FF34 /* ValidationTests.swift in Sources */,
3111CE8420A7636E008315E2 /* SessionManagerTests.swift in Sources */,
3111CE8420A7636E008315E2 /* SessionTests.swift in Sources */,
31C2B0F020B271370089BA7C /* TLSEvaluationTests.swift in Sources */,
3111CE9B20A7EC57008315E2 /* URLProtocolTests.swift in Sources */,
317A6A7620B2207F00A9FEC5 /* DownloadTests.swift in Sources */,
Expand Down Expand Up @@ -1476,7 +1476,7 @@
F829C6BF1A7A950600A2CD59 /* RequestTests.swift in Sources */,
31727423218BB9A50039FFCC /* HTTPBin.swift in Sources */,
31EBD9C220D1D89C00D1FF34 /* ValidationTests.swift in Sources */,
3111CE8520A7636F008315E2 /* SessionManagerTests.swift in Sources */,
3111CE8520A7636F008315E2 /* SessionTests.swift in Sources */,
31C2B0F120B271370089BA7C /* TLSEvaluationTests.swift in Sources */,
3111CE9C20A7EC58008315E2 /* URLProtocolTests.swift in Sources */,
317A6A7720B2208000A9FEC5 /* DownloadTests.swift in Sources */,
Expand Down
11 changes: 11 additions & 0 deletions Alamofire.xcodeproj/xcshareddata/xcschemes/Alamofire iOS.xcscheme
Expand Up @@ -41,7 +41,18 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableThreadSanitizer = "YES"
codeCoverageEnabled = "YES"
onlyGenerateCoverageForSpecifiedTargets = "YES"
shouldUseLaunchSchemeArgsEnv = "NO">
<CodeCoverageTargets>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "F8111E3219A95C8B0040E7D1"
BuildableName = "Alamofire.framework"
BlueprintName = "Alamofire iOS"
ReferencedContainer = "container:Alamofire.xcodeproj">
</BuildableReference>
</CodeCoverageTargets>
<Testables>
<TestableReference
skipped = "NO">
Expand Down
Expand Up @@ -42,7 +42,17 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableThreadSanitizer = "YES"
codeCoverageEnabled = "YES"
onlyGenerateCoverageForSpecifiedTargets = "YES"
shouldUseLaunchSchemeArgsEnv = "NO">
<CodeCoverageTargets>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4DD67C0A1A5C55C900ED2280"
BuildableName = "Alamofire.framework"
BlueprintName = "Alamofire macOS"
ReferencedContainer = "container:Alamofire.xcodeproj">
</BuildableReference>
</CodeCoverageTargets>
<Testables>
<TestableReference
skipped = "NO">
Expand Down
11 changes: 11 additions & 0 deletions Alamofire.xcodeproj/xcshareddata/xcschemes/Alamofire tvOS.xcscheme
Expand Up @@ -41,7 +41,18 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableThreadSanitizer = "YES"
codeCoverageEnabled = "YES"
onlyGenerateCoverageForSpecifiedTargets = "YES"
shouldUseLaunchSchemeArgsEnv = "NO">
<CodeCoverageTargets>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "4CF626EE1BA7CB3E0011A099"
BuildableName = "Alamofire.framework"
BlueprintName = "Alamofire tvOS"
ReferencedContainer = "container:Alamofire.xcodeproj">
</BuildableReference>
</CodeCoverageTargets>
<Testables>
<TestableReference
skipped = "NO">
Expand Down
7 changes: 1 addition & 6 deletions Source/AFError.swift
Expand Up @@ -160,10 +160,6 @@ public enum AFError: Error {
self.result = result
}
}
/// Trust evaluation was failed for an unknown reason. Usually this means the evaluator failed but didn't throw
/// an error.
case unknown(host: String)
/// `allHostsMustBeEvaluated` was `true` but no evaluator was found for the associated host.
case noRequiredEvaluator(host: String)
/// No certificates were found with which to perform the trust evaluation.
case noCertificatesFound
Expand Down Expand Up @@ -198,6 +194,7 @@ public enum AFError: Error {
}

extension Error {
/// Returns the instance cast as an `AFError`.
public var asAFError: AFError? {
return self as? AFError
}
Expand Down Expand Up @@ -581,8 +578,6 @@ extension AFError.ResponseValidationFailureReason {
extension AFError.ServerTrustFailureReason {
var localizedDescription: String {
switch self {
case .unknown:
return "Server trust evaluation failed but no specific error was thrown."
case let .noRequiredEvaluator(host):
return "A ServerTrustEvaluating value is required for host \(host) but none was found."
case .noCertificatesFound:
Expand Down
2 changes: 1 addition & 1 deletion Source/Alamofire.swift
Expand Up @@ -24,7 +24,7 @@

import Foundation

/// Global namespace containing API for the `default` `SessionManager` instance.
/// Global namespace containing API for the `default` `Session` instance.
public enum AF {
// MARK: - Data Request

Expand Down
42 changes: 37 additions & 5 deletions Source/HTTPHeaders.swift
Expand Up @@ -48,6 +48,22 @@ public struct HTTPHeaders {
dictionary.forEach { update(HTTPHeader(name: $0.key, value: $0.value)) }
}

/// Case-insensitively updates or appends an `HTTPHeader` into the instance using the provided `name` and `value`.
///
/// - Parameters:
/// - name: The `HTTPHeader` name.
/// - value: The `HTTPHeader value.
public mutating func add(name: String, value: String) {
update(HTTPHeader(name: name, value: value))
}

/// Case-insensitively updates or appends the provided `HTTPHeader` into the instance.
///
/// - Parameter header: The `HTTPHeader` to update or append.
public mutating func add(_ header: HTTPHeader) {
update(header)
}

/// Case-insensitively updates or appends an `HTTPHeader` into the instance using the provided `name` and `value`.
///
/// - Parameters:
Expand All @@ -57,7 +73,7 @@ public struct HTTPHeaders {
update(HTTPHeader(name: name, value: value))
}

/// Case-insensitively updates or apprends the provided `HTTPHeader` into the instance.
/// Case-insensitively updates or appends the provided `HTTPHeader` into the instance.
///
/// - Parameter header: The `HTTPHeader` to update or append.
public mutating func update(_ header: HTTPHeader) {
Expand All @@ -80,7 +96,7 @@ public struct HTTPHeaders {

/// Sort the current instance by header name.
mutating public func sort() {
return headers.sort { $0.name < $1.name }
headers.sort { $0.name < $1.name }
}

/// Returns an instance sorted by header name.
Expand All @@ -100,7 +116,6 @@ public struct HTTPHeaders {
return headers[index].value
}


/// Case-insensitively access the header with the given name.
///
/// - Parameter name: The name of the header.
Expand Down Expand Up @@ -198,6 +213,14 @@ extension HTTPHeader: CustomStringConvertible {
}

extension HTTPHeader {
/// Returns an `Accept-Charset` header.
///
/// - Parameter value: The `Accept-Charset` value.
/// - Returns: The header.
public static func acceptCharset(_ value: String) -> HTTPHeader {
return HTTPHeader(name: "Accept-Charset", value: value)
}

/// Returns an `Accept-Language` header.
///
/// Alamofire offers a default Accept-Language header that accumulates and encodes the system's preferred languages.
Expand Down Expand Up @@ -232,10 +255,19 @@ extension HTTPHeader {
return authorization("Basic \(credential)")
}

/// Returns a `Bearer` `Authorization` header using the `bearerToken` provided
///
/// - Parameter bearerToken: The bearer token.
/// - Returns: The header.
public static func authorization(bearerToken: String) -> HTTPHeader {
return authorization("Bearer \(bearerToken)")
}

/// Returns an `Authorization` header.
///
/// Alamofire provides a built-in method to produce Basic Authorization headers. Use
/// `HTTPHeader.authorization(username: password:)`.
/// Alamofire provides built-in methods to produce `Authorization` headers. For a Basic `Authorization` header use
/// `HTTPHeader.authorization(username: password:)`. For a Bearer `Authorization` header, use
/// `HTTPHeader.authorization(bearerToken:)`.
///
/// - Parameter value: The `Authorization` value.
/// - Returns: The header.
Expand Down
2 changes: 1 addition & 1 deletion Source/MultipartFormData.swift
Expand Up @@ -551,7 +551,7 @@ open class MultipartFormData {
if let fileName = fileName { disposition += "; filename=\"\(fileName)\"" }

var headers: HTTPHeaders = [.contentDisposition(disposition)]
if let mimeType = mimeType { headers.update(.contentType(mimeType)) }
if let mimeType = mimeType { headers.add(.contentType(mimeType)) }

return headers
}
Expand Down

0 comments on commit 6248e8d

Please sign in to comment.