Charles 抓包map local 修改 映射到本地数据 出现如下报错
返回ErrorUrl==https://xxxx
返回Error==Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/plain" UserInfo={NSLocalizedDescription=Request failed: unacceptable content-type: text/plain, NSErrorFailingURLKey=https://xxx?timestamp=1688982930645, com.alamofire.serialization.response.error.data={length = 7601, bytes = 0x7b0a0922 72657422 3a207472 75652c0a ... 7d5d0a09 7d5d0a7d }, com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x282fda420> { URL: https://read-beta.xwuad.com/pagerecommend/v2/recommendList?timestamp=1688982930645 } { Status Code: 200, Headers {
"Content-Length" : [
"7601"
],
"Content-Type" : [
"text\/plain"
],
"x-charles-map-local" : [
"\/Users\/leihuai\/Desktop\/firstpage.txt"
]
} }}
意思很明显缺少 text/plain 的数据解析格式,检查代码发现 response中明显已经添加了
netManager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html",@"text/plain", nil];
解决办法,可以对Charles做如下操作