I can't seem to be able to completely remove headers from a request. I tried subclassing a NSURLRequest and setting header values to nil, but they still show up. The closest thing I was able to do is this:
-(instancetype)init{
self = [super initWithURL:[NSURL URLWithString:@"http://www.example.com/"]];
if(self){
self.HTTPMethod = @"POST";
self.HTTPBody = [@"65000,100" dataUsingEncoding:NSUTF8StringEncoding];
[self setValue:@"" forHTTPHeaderField:@"Host"];
[self setValue:@"" forHTTPHeaderField:@"User-Agent"];
[self setValue:@"" forHTTPHeaderField:@"Content-Type"];
[self setValue:@"" forHTTPHeaderField:@"Connection"];
[self setValue:@"" forHTTPHeaderField:@"Accept"];
[self setValue:@"" forHTTPHeaderField:@"Accept-Language"];
[self setValue:@"" forHTTPHeaderField:@"Accept-Encoding"];
[self setValue:@"" forHTTPHeaderField:@"Content-Length"];
}
return self;
}
This creates these headers:
POST / HTTP/1.1
Host:
Content-Type:
Content-Length: 9
Accept:
User-Agent:
Accept-Language:
Accept-Encoding:
Connection: keep-alive
65000,100
And ideally I'm trying to just send on the request
65000,100
Maybe using a NSURLSessionTask with a NSURLRequest is not the way to do this, so if that is the case, please advise.