Swiftpack.co - Package - amzn/smoke-http

Build - Master Branch Linux Swift 4.1 Compatible Swift 4.1 Compatible Join the Smoke Server Side community on gitter Apache 2

SmokeHTTP

SmokeHTTP contains the library SmokeHTTPClient which will allow someone building a specific client that requires unique use-cases for HTTP parameters to utilize a generic HTTPClient that allows the user to implement their own delegates that handles client-specific HTTP logic.

The benefit of this package is to consolidate all HTTPClient logic into one location, while other clients are built to utilize this client while defining their own specific delegates.

SmokeHTTPClient

To use SmokeHTTPClient, a user can instantiate an HTTPClient in the constructor of their specific client with instantiated delegates (HTTPClientDelegate, HTTPClientChannelInboundHandlerDelegate) that are defined by the client-specific logic.

Getting Started

Step 1: Add the SmokeHTTP dependency

SmokeHTTP uses the Swift Package Manager. To use the framework, add the following dependency to your Package.swift-

dependencies: [
    .package(url: "https://github.com/amzn/smoke-http.git", from: "1.0.0")
]

.target(
    name: ...,
    dependencies: [..., "SmokeHTTPClient"]),

Step 2: Construct a HTTPClient

Construct a HTTPClient using the following code-

import SmokeHTTPClient

let httpClient = HTTPClient(endpointHostName: endpointHostName,
                            endpointPort: endpointPort,
                            contentType: contentType,
                            clientDelegate: clientDelegate,
                            connectionTimeoutSeconds: connectionTimeoutSeconds)

where clientDelegate conforms to the HTTPClientDelegate protocol.

License

This library is licensed under the Apache 2.0 License.

Github

link
Stars: 36
Help us keep the lights on

Releases

1.0.0 - Apr 4, 2019

This release of SmokeHTTP provides compatibility with Swift 4.1 and Swift 4.2 using SwiftNIO 1.x.

0.9.0 - Apr 2, 2019

Implement a number of internal fixes to be more efficient in memory usage, including using NIOFoundationCompat to convert directly from a ByteBuffer to Foundation.Data when receiving the response in HTTPClient.

0.8.0 - Mar 26, 2019

Add a key transform strategy for encoding and decoding shapes with a passthrough option, an option to capitalise and de-capitalise the first character and a custom transform. This is enable use cases where there is a known mapping from the Codable instance to the serialised form that cannot be fully expressed as CodingKeys (the mapping is different in different circumstances.

0.7.3 - Mar 13, 2019

Fix crash on Linux branch of getRetryInterval().

0.7.2 - Mar 12, 2019

Fixed for a fatal error when the retry configuration as 0 as the upper bound retry duration.