/** cache for resolveAndCheckIfFirewalled() */
static Hashtable resolvedHosts = new Hashtable();
- /** if any request encounters an IOException, the entire HTTP connection is invalidated */
- boolean invalid = false;
-
/** true iff we are allowed to skip the resolve check (only allowed when we're downloading the PAC script) */
boolean skipResolveCheck = false;
Semaphore blockOn = null;
Semaphore releaseMe = null;
synchronized(this) {
- if (invalid) throw new HTTPException("connection failed on a previous pipelined call");
try {
connect();
sendRequest(contentType, content);
} catch (IOException e) {
- invalid = true;
+ sock = null;
+ in = null;
throw e;
}
blockOn = okToRecieve;
boolean doRelease = true;
try {
if (blockOn != null) blockOn.block();
- if (invalid) throw new HTTPException("connection failed on a previous pipelined call");
+
+ // previous call wrecked the socket connection, but we already sent our request, so we can't just retry --
+ // this could cause the server to receive the request twice, which could be bad (think of the case where the
+ // server call causes Amazon.com to ship you an item with one-click purchasing).
+ if (sock == null)
+ throw new HTTPException("a previous pipelined call messed up the socket");
Hashtable h = in == null ? null : parseHeaders(in);
if (h == null) {
}
- } catch (IOException e) { invalid = true; throw e;
+ } catch (IOException e) { sock = null; in = null; throw e;
} finally { if (doRelease) releaseMe.release();
}
}
}
return ret;
} finally {
- if (!good) invalid = true;
+ if (!good) { this.HTTP.sock = null; this.HTTP.in = null; }
}
}