URLSession how to inflate content-type application/binary with encoding deflate

I'm processing a POST response from a web server where the content-type is application/binary and the content-encoding is deflate.

I'm using XCode 13.x with pure SwiftUI. How can I "inflate" the response before passing the bytes on to a connected bluetooth printer via the session outputStream?

I cannot change the response from the server.

How can I "inflate" the response before passing the bytes

Taking a quick look around your probably want checkout COMPRESSION_ZLIB and compression_decode_buffer. There is also the article for Compressing and Decompressing Data with Buffer Compression, which isn't exactly what you are looking for but should get you started with some code examples.

What API are you using to run the POST request? If you use our recommended high-level API, NSURLSession, it’ll undo the deflate transfer content encoding for you.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

URLSession how to inflate content-type application/binary with encoding deflate
 
 
Q