pruthvikar / GZIP

Swift GZIP data compression for macOS and Linux

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gzip

Build Status Platforms Package Managers

Blog Twitter Czechboy0

gzip data compression from Swift, OS X & Linux ready

Usage

Works on Data or anything Gzippable

let myData = ... //Data
let myGzipCompressedData = try myData.gzipCompressed() //Data
...
let myGzipUncompressedData = try myGzipCompressedData.gzipUncompressed() //Data
... //PROFIT!

Middleware to suport gzipped content in HTTPClient.

let request = ... //Request
let response = try client.request(request, middleware: [GzipMiddleware()])

Please note, that GzipMiddleware should be placed at the end of a chain:

let response = try client.request(request, middleware: [ContentNegotiationMiddleware(mediaTypes: [.json], mode: .client), GzipMiddleware()])

Details

As this library uses a SwiftPM-compatible source of zlib, you don't need to install anything manually before using it. Even though both OS X and Linux have a preinstalled version of zlib, unfortunately each has a different version, making its potential use inconsistent. In our case everything is compiled from source, so you can be sure to get the same results everywhere. ๐Ÿ’ฏ

Installation

Swift Package Manager

.Package(url: "https://github.com/Zewo/gzip.git", majorVersion: 0, minor: 8)

๐Ÿ’ Contributing

Please create an issue with a description of your problem or open a pull request with a fix.

๐Ÿ‘ Thanks

This project was initially inspired by NSData+GZIP, thank you!

โœŒ๏ธ License

MIT

๐Ÿ‘ฝ Author

Honza Dvorsky - http://honzadvorsky.com, @czechboy0

About

Swift GZIP data compression for macOS and Linux

License:MIT License


Languages

Language:Swift 100.0%