简体   繁体   中英

Json data truncated on cell network ok on wifi

Using the following code to retrieve data via a php file from MySQL works great on wifi but not on mobile it seems to truncate the response. Any help to approach debugging this would be much appreciated. See print outputs pasted into code below for cell v wifi

func get(){

let urlcustom = "http://myserver.com/swiftly/phpget.php?team_id=\(theteam)"
let url = URL(string: urlcustom)
let data = try? Data(contentsOf: url!)
values = try! JSONSerialization.jsonObject(with: data!, options: JSONSerialization.ReadingOptions.mutableContainers) as! NSArray
tableView.reloadData()
print("get ran \(data)")
// mobile phone cell connection - FAIL
// get ran Optional(<5b5d>)

// Wifi Connection
//get ran Optional(<5b7b2269 64223a22 31222c22 7465616d 5f696422 3a223122 2c226e61 6d65223a 22457669 65205072 6f637465 72222c22 646f6222 3a223230 30362d30 312d3033 222c2270 686f746f 223a2222 7d5d>)


}

I added this to all my files :

<?php 
header("Content-Type: application/json"); header("Expires: 0"); 
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); 
header("Cache-Control: no-store, no-cache, must-revalidate"); 
header("Cache-Control: post-check=0, pre-check=0", false); 
header("Pragma: no-cache"); 
$host='localhost';

All works now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM