Re: NSURLConnection: setting Connection: close HTTP header
Re: NSURLConnection: setting Connection: close HTTP header
- Subject: Re: NSURLConnection: setting Connection: close HTTP header
- From: Nicolas Berloquin <email@hidden>
- Date: Fri, 7 Oct 2005 12:43:24 +0200
thanks for your quick answer !
On Oct 6, 2005, at 10:24 PM, Becky Willrich wrote:
Currently, there's no way to cause a Connection: close header to be
emitted; NSURLConnection's HTTP implementation tries to keep alive
connections as long as possible, and will change the Connection:
close as you discovered. If you want to guarantee that the
connection dies after a single request, currently, the best you can
do is use CFNetwork directly.
:(
I'm very satisfied with the simplicity of NSURLConnection, and I
don't like the over-helping (remember heart of gold's computer ? :D)
approach. Maybe future versions could have a settable flag for this
feature ?
It is not specified (in anything I read) that NSURLConnection would
override some headers when I use setAllHTTPHeaderFields:.
Maybe a 'neverOverride' set to false as a default would be clean
enough (and easy enough) to implement ?
The reason I need the connection: close is that I interact with
bittorrent trackers that tend to be quite paranoid, and which
included an anti-faking mechanism that implies rejecting anything
that smells like a browser. And they seem to dislike keep-alive
connections.
But anyway I'm sure, that 1) mentioning the internal modifications
made after setAllHTTPHeaderFields: should be mentioned in the docs,
and that 2) other people may be interested in the simple suggestion I
expressed above.
Thanks for your help ^_^
To answer your side question, no, you don't have to set the Host:
header yourself; NSURLConnection will do enough touch-up to
guarantee the integrity of the HTTP transaction, and that includes
setting the Host field.
Hope that helps,
REW
On Oct 6, 2005, at 11:22 AM, Nicolas Berloquin wrote:
Hello !
I'm using an NSMutableURLRequest to launch a [NSURLConnection
connectionWithRequest: delegate:] request.
Before opening the connexion, I try to set all the HTTP header
fields as follows, but the Connection: close is
always transformed into a 'keep-alive' connection (as I verified
with tcpdump).
Is there anything I should do for it to work ?
[trackerRequestNSURL setAllHTTPHeaderFields:
[NSDictionary dictionaryWithObjectsAndKeys:
@"BitsOnWheels1.0PR1.5b1", @"User-Agent",
@"close",
@"Connection",
@"gzip",
@"Accept-Encoding",
@"*/*",
@"Accept",
_realHost,
@"Host",
nil]
];
PS as a side question : do I have to set the Host: field myself in
this case, or will it be filled by cocoa ?
thanks !
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden