I have written Android apps that take GZipped Json data from a HTTP response. Now I want to write some IPhone apps that do the same thing.
What class and approaches are needed to handle GZipped Json data using Swift?
I have written Android apps that take GZipped Json data from a HTTP response. Now I want to write some IPhone apps that do the same thing.
What class and approaches are needed to handle GZipped Json data using Swift?
On swift side:
On php side:
Decoding gzip - To unzip received (gzipped) post data (from your iOS App) use this:
// Read the post data
$handle = fopen("php://input", "rb");
$raw_post_data = '';
while (!feof($handle)) {
$raw_post_data .= fread($handle, 8192);
}
fclose($handle);
// unzip the post data
$raw_post_data_unzipped = gzdecode($raw_post_data);
Encoding to gzip - To send gzipped responses (to your iOS App) add below line somewhere at the beginning of your php file.
ob_start('ob_gzhandler');