}
if ((client.query != null) && (client.query.length() > 0)) {
url += "?" + client.query;
}
MimeHeaders clientHeaders = client.headers;
/*
* "Proxy-Connection" may be used (instead of just "Connection")
* to keep alive a connection between a client and this proxy.
*/
String pc = clientHeaders.get("Proxy-Connection");
if (pc != null) {
client.connectionHeader = "Proxy-Connection";
client.keepAlive = pc.equalsIgnoreCase("Keep-Alive");
}
HttpRequest.removePointToPointHeaders(clientHeaders, false);
HttpRequest target = new HttpRequest(url);
try {
MimeHeaders targetHeaders = target.requestHeaders;
target.setMethod(client.method);
clientHeaders.copyTo(targetHeaders);
/* targetHeaders.add("Via", client.protocol + via);*/
/*
* We might need to authenticate to a target proxy.
*/
if ((proxyHost != null)
&& proxyTester.useProxy(target.host, target.port)) {
target.setProxy(proxyHost, proxyPort);
if (auth != null) {
targetHeaders.add("Proxy-Authorization", auth);
}
}
if (client.postData != null) {
OutputStream out = target.getOutputStream();
out.write(client.postData);
out.close();
}
target.connect();
targetHeaders = target.responseHeaders;
HttpRequest.removePointToPointHeaders(targetHeaders, true);
clientHeaders = client.responseHeaders;
targetHeaders.copyTo(clientHeaders);
try {
clientHeaders.add("Via",
target.status.substring(0, 8) + via);
} catch (StringIndexOutOfBoundsException e) {
clientHeaders.add("Via", via);