默认的请求头是这样的
{
"Content-Length" = 1301;
"Content-Type" = "text/html;charset=UTF-8";
Date = "Mon, 24 July 2017 10:53:06 GMT";
Server = "Apache-Coyote/1.1";
}
还可以使用花瓶Charles抓包看一下请求头
设置请求头如下:
//设置请求内容的类型
[manager.requestSerializer setValue:@"application/json;charset=utf-8" forHTTPHeaderField:@"Content-Type"];
//设置请求内容的长度
[manager.requestSerializer setValue:[NSString stringWithFormat:@"%ld", (unsigned long)[jsonStr length]] forHTTPHeaderField:@"Content-Length"];
//设置请求的编码类型
[manager.requestSerializer setValue:@"gzip" forHTTPHeaderField:@"Content-Encoding"];