Description
RealHTTP is a lightweight yet powerful async/await based client-side HTTP library made in Swift. The goal of this project is to make an easy to use, effortless http client based upon all the best new Swift features.
RealHTTP alternatives and similar libraries
Based on the "Network" category.
Alternatively, view RealHTTP alternatives based on common mentions on social networks and blogs.
-
Perfect
Server-side Swift. The Perfect core toolset and framework for Swift Developers. (For mobile back-end development, website and API development, and more…) -
Reachability.swift
Replacement for Apple's Reachability re-written in Swift with closures -
swifter
Tiny http server engine written in Swift programming language. -
SwiftSoup
SwiftSoup: Pure Swift HTML Parser, with best of DOM, CSS, and jquery (Supports Linux, iOS, Mac, tvOS, watchOS) -
Netfox
A lightweight, one line setup, iOS / OSX network debugging library! 🦊 -
SwiftHTTP
Thin wrapper around NSURLSession in swift. Simplifies HTTP requests. -
APIKit
Type-safe networking abstraction layer that associates request type with response type. -
Swifton
A Ruby on Rails inspired Web Framework for Swift that runs on Linux and OS X -
CocoaMQTT
MQTT 5.0 client library for iOS and macOS written in Swift -
Zewo
Lightweight library for web server applications in Swift on macOS and Linux powered by coroutines. -
ResponseDetective
Sherlock Holmes of the networking layer. :male_detective: -
SwiftWebSocket
A high performance WebSocket client library for swift. -
BlueSocket
Socket framework for Swift using the Swift Package Manager. Works on iOS, macOS, and Linux. -
Connectivity
🌐 Makes Internet connectivity detection more robust by detecting Wi-Fi networks without Internet access. -
WKZombie
WKZombie is a Swift framework for iOS/OSX to navigate within websites and collect data without the need of User Interface or API, also known as Headless browser. It can be used to run automated tests / snapshots and manipulate websites using Javascript. -
Pitaya
🏇 A Swift HTTP / HTTPS networking library just incidentally execute on machines -
Blackfish
A minimal, fast and unopinionated web framework for Swift -
Express
Swift Express is a simple, yet unopinionated web application server written in Swift -
PeerKit
An open-source Swift framework for building event-driven, zero-config Multipeer Connectivity apps -
Heimdallr.swift
Easy to use OAuth 2 library for iOS, written in Swift. -
Socks
🔌 Non-blocking TCP socket layer, with event-driven server and client. -
Embassy
Super lightweight async HTTP server library in pure Swift runs in iOS / MacOS / Linux -
Reach
A simple class to check for internet connection availability in Swift. -
Digger
Digger is a lightweight download framework that requires only one line of code to complete the file download task -
SOAPEngine
This generic SOAP client allows you to access web services using a your iOS app, Mac OS X app and AppleTV app. -
Transporter
A tiny library makes uploading and downloading easier -
SwiftyOAuth
A simple OAuth library for iOS with a built-in set of providers -
XcodeServerSDK
Access Xcode Server API with native Swift objects. -
BigBrother
Automatically sets the network activity indicator for any performed request.
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of RealHTTP or a related project?
Popular Comparisons
README
RealHTTP is a lightweight yet powerful async/await based client-side HTTP library made in Swift.
The goal of this project is to make an easy to use, effortless http client based upon all the best new Swift features.
What you will get?
This is a simple http call in RealHTTP
let todo = try await HTTPRequest("https://jsonplaceholder.typicode.com/todos/1")
.fetch(Todo.self)
One line of code, including the automatic decode from JSON to object.
Of course you can fully configure the request with many other parameters, take a look here:
let req = HTTPRequest {
// Setup default params
$0.url = URL(string: "https://.../login")!
$0.method = .post
$0.timeout = 15
// Setup some additional settings
$0.redirectMode = redirect
$0.maxRetries = 4
$0.headers = HTTPHeaders([
.init(name: .userAgent, value: myAgent),
.init(name: "X-API-Experimental", value: "true")
])
// Setup URL query params & body
$0.addQueryParameter(name: "full", value: "1")
$0.addQueryParameter(name: "autosignout", value: "30")
$0.body = .json(["username": username, "pwd": pwd])
}
let _ = try await req.fetch()
This is fully type-safe too!
What about the stubber?
Integrated stubber is perfect to write your own test suite:
That's a simple stubber which return the original request as response:
let echoStub = HTTPStubRequest().match(urlRegex: "*").stubEcho()
HTTPStubber.shared.add(stub: echoStub)
HTTPStubber.shared.enable()
Of course you can fully configure your stub with rules (regex, URI template and more):
// This is a custom stubber for any post request.
var stub = HTTPStubRequest()
.stub(for: .post, { response in
response.responseDelay = 5
response.headers = HTTPHeaders([
.contentType: HTTPContentType.bmp.rawValue,
.contentLength: String(fileSize,
])
response.body = fileContent
})
HTTPStubber.shared.add(stub: stub)
That's all!
Feature Highlights
RealHTTP offers lots of features and customization you can found in our extensive documentation and test suite.
Some of them are:
- Async/Await native support
- Requests queue built in
- Based upon native URLSession technology
- Advanced retry mechanisms
- Chainable & customizable response validators like Node's Express.js
- Automatic Codable object encoding/decoding
- Customizable decoding of objects
And for pro users:
- Powerful integrated HTTP Stub for your mocks
- Combine publisher adapter
- URI templating system
- Resumable download/uploads with progress tracking
- Native Multipart Form Data support
- Advanced URL connection metrics collector
- SSL Pinning, Basic/Digest Auth
- TSL Certificate & Public Key Pinning
- cURL debugger
Documentation
RealHTTP is provided with an extensive documentation.
- [1 - Introduction](./Documentation/1.Introduction.md)
- [2 - Build & Execute a Request](./Documentation/2.Build_Request.md#build--execute-a-request)
- [Initialize a Request](./Documentation/2.Build_Request.md#initialize-a-request)
- [Standard](./Documentation/2.Build_Request.md#standard)
- [URI Template](./Documentation/2.Build_Request.md#uri-template)
- [Builder Pattern](./Documentation/2.Build_Request.md#builder-pattern)
- [Setup Query Parameters](./Documentation/2.Build_Request.md#setup-query-parameters)
- [Setup Headers](./Documentation/2.Build_Request.md#setup-headers)
- [Setup Request Body](./Documentation/2.Build_Request.md#setup-request-body)
- [URL Query Parameters](./Documentation/2.Build_Request.md#url-query-parameters)
- [Raw Data & Stream](./Documentation/2.Build_Request.md#raw-data--stream)
- [Plain Strings](./Documentation/2.Build_Request.md#plain-strings)
- [JSON Data](./Documentation/2.Build_Request.md#json-data)
- [Multipart-Form-Data](./Documentation/2.Build_Request.md#multipart-form-data)
- [The HTTP Client](./Documentation/2.Build_Request.md#the-http-client)
- [Shared Client](./Documentation/2.Build_Request.md#shared-client)
- [Custom Client](./Documentation/2.Build_Request.md#custom-client)
- [Execute a Request](./Documentation/2.Build_Request.md#execute-a-request)
- [Modify a Request](./Documentation/2.Build_Request.md#modify-a-request)
- [Cancel a Request](./Documentation/2.Build_Request.md#cancel-a-request)
- [The HTTP Response](./Documentation/2.Build_Request.md#the-http-response)
- [Decode using Codable & Custom Decoding](./Documentation/2.Build_Request.md#decode-using-codable--custom-decoding)
- [Decode Raw JSON using JSONSerialization](./Documentation/2.Build_Request.md#decode-raw-json-using-jsonserialization)
- [3 - Advanced HTTP Client](./Documentation/3.Advanced_HTTPClient.md#advanced-http-client)
- [Why using a custom HTTPClient](./Documentation/3.Advanced_HTTPClient.md#why-using-a-custom-httpclient)
- [Validate Responses: Validators](./Documentation/3.Advanced_HTTPClient.md#validate-responses-validators)
- [Approve the response](./Documentation/3.Advanced_HTTPClient.md#approve-the-response)
- [Fail with error](./Documentation/3.Advanced_HTTPClient.md#fail-with-error)
- [Retry with strategy](./Documentation/3.Advanced_HTTPClient.md#retry-with-strategy)
- [The Default Validator](./Documentation/3.Advanced_HTTPClient.md#the-default-validator)
- [Custom Validators](./Documentation/3.Advanced_HTTPClient.md#custom-validators)
- [Retry After [Another] Call](./Documentation/3.Advanced_HTTPClient.md#retry-after-another-call)
- [4 - Handle Large Data Request](./Documentation/4.Handle_LargeData_Requests.md#handle-large-data-request)
- [Track Progress](./Documentation/4.Handle_LargeData_Requests.m#track-progress)
- [Cancel Downloads with resumable data](./Documentation/4.Handle_LargeData_Requests.md#cancel-downloads-with-resumable-data)
- [Resume Downloads](./Documentation/4.Handle_LargeData_Requests.md#resume-downloads)
- [5 - Other Debugging Tools](./Documentation/5.Other_Debugging_Tools.md#other-debugging-tools)
- [cURL Command Output](./Documentation/5.Other_Debugging_Tools.md#curl-command-output)
- [Monitor Connection Metrics](./Documentation/5.Other_Debugging_Tools.md#monitor-connection-metrics)
- [6 - HTTP Stubber](./Documentation/6.Stubber.md#http-stubber)
- [Stub a Request](./Documentation/6.Stubber.md#stub-a-request)
- [Stub Matchers](./Documentation/6.Stubber.md#stub-matchers)
- [Echo Stub](./Documentation/6.Stubber.md#echo-stub)
- [URI Matcher](./Documentation/6.Stubber.md#uri-matcher)
- [JSON Matcher](./Documentation/6.Stubber.md#json-matcher)
- [Body Matcher](./Documentation/6.Stubber.md#body-matcher)
- [URL Matcher](./Documentation/6.Stubber.md#url-matcher)
- [Custom Matcher](./Documentation/6.Stubber.md#custom-matcher)
- [Add Ignore Rule](./Documentation/6.Stubber.md#add-ignore-rule)
- [Unhandled Rules](./Documentation/6.Stubber.md#unhandled-rules) ## Test
RealHTTP has an extensive unit test suite which covers many of the standard and edge cases including request build, parameter encoding, queuing and retry strategies.
See the XCTest suite inside Tests/RealHTTPTests
folder.
Requirements
RealHTTP can be installed in any platform which supports:
- iOS 13+, macOS Catalin+, watchOS 6+, tvOS 13+
- Xcode 13.2+
- Swift 5.5+
Installation
Swift Package Manager
Aadd it as a dependency in a Swift Package, add it to your Package.swift:
dependencies: [
.package(url: "https://github.com/immobiliare/RealHTTP.git", from: "1.0.0")
]
And add it as a dependency of your target:
targets: [
.target(name: "MyTarget", dependencies: [
.product(name: "https://github.com/immobiliare/RealHTTP.git", package: "RealHTTP")
])
]
In Xcode 11+ you can also navigate to the File menu and choose Swift Packages -> Add Package Dependency..., then enter the repository URL and version details.
CocoaPods
RealHTTP can be installed with CocoaPods by adding pod 'RealHTTP' to your Podfile.
pod 'RealHTTP'
Powered Apps
RealHTTP was created by the amazing mobile team at ImmobiliareLabs, the Tech dept at Immobiliare.it, the first real estate site in Italy.
We are currently using RealHTTP in all of our products.
If you are using RealHTTP in your app drop us a message, we'll add below.
Support & Contribute
Made with ❤️ by ImmobiliareLabs & Contributors
We'd love for you to contribute to RealHTTP!
If you have any questions on how to use RealHTTP, bugs and enhancement please feel free to reach out by opening a GitHub Issue.