更新时间:2023-11-29 14:25:28
在 NSURLConnection 的 delegate 方法中,可以获得响应的头部,从中可以获得内容类型.如果从服务器正确设置了内容类型,您将在此处正确获得响应的内容类型.
In delegate method of NSURLConnection, you can get header of response, from which you can get content type. If content type is set correctly from server, you will get content type in response over here correctly.
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{
NSDictionary *dicFields = [response allHeaderFields];
}