Change default header NSMutableURLRequest

I need to change the default HTTP " Connection" in header to a NSMutableURLRequest"close" value instead of a "keep-alive". What is the best practice?

I tried to use the TCP layer and create an HTTP request myself + use GCDAsyncSocket. This works, but I think this solution does not look very good.

Thank.

+4
source share
1 answer

Easier as you might think:

NSMutableURLRequest* request = [NSMutableURLRequest alloc] initWithURL:url];

[request setValue:@"close" forHTTPHeaderField:@"Connection"];

If u wants to add a value:

[request addValue:VALUE forHTTPHeaderField:@"Connection"];
+4
source

All Articles