I'm trying to make a simple HTTP/1.0 request where the Connection header is
set to Close. I have the following basic code:
HttpParams params = new SyncBasicHttpParams();
// set the version to 1.0
params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION,
HttpVersion.HTTP_1_0.toString());
httpclient = new DefaultHttpClient(params);
// I attempt to force Connection: Close here
httpclient.setKeepAliveStrategy(new ConnectionKeepAliveStrategy() {
public long getKeepAliveDuration(HttpResponse response, HttpContext
context) {
return 0;
}
});
BasicHttpEntityEnclosingRequest request = new
BasicHttpEntityEnclosingRequest("POST", baseUrl, HttpVersion.HTTP_1_0);
HttpResponse response = httpclient.execute(httpHost, request);
A few questions:
1) Why doesn't setKeepAliveStrategy() for the client seem to actually do
that... set the keep alive strategy?
2) Why do I have to set the version of the request a second time: once with
the client via a parameter, and again with the request. Setting the
parameter value in the client seems to have no affect.
3) Finally, how do I force Connection: Close instead of Connection:
Keep-Alive?
Thanks!
Bill-