debugs(81, 1, "fwdNegotiateSSL: Error negotiating SSL connection on FD " << fd <<
": " << ERR_error_string(ERR_get_error(), NULL) << " (" << ssl_error <<
"/" << ret << "/" << errno << ")");
- ErrorState *anErr = errorCon(ERR_SECURE_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request);
+ ErrorState *const anErr = makeConnectingError(ERR_SECURE_CONNECT_FAIL);
#ifdef EPROTO
anErr->xerrno = EPROTO;
debugs(17, 4, "fwdConnectDone: Unknown host: " << request->GetHost());
- ErrorState *anErr = errorCon(ERR_DNS_FAIL, HTTP_SERVICE_UNAVAILABLE, request);
+ ErrorState *const anErr = makeConnectingError(ERR_DNS_FAIL);
anErr->dnsError = dns.error;
comm_close(server_fd);
} else if (status != COMM_OK) {
assert(fs);
- ErrorState *anErr = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request);
+ ErrorState *const anErr = makeConnectingError(ERR_CONNECT_FAIL);
anErr->xerrno = xerrno;
fail(anErr);
return reforwardableStatus(s);
}
+/**
+ * Create "503 Service Unavailable" or "504 Gateway Timeout" error depending
+ * on whether this is a validation request. RFC 2616 says that we MUST reply
+ * with "504 Gateway Timeout" if validation fails and cached reply has
+ * proxy-revalidate, must-revalidate or s-maxage Cache-Control directive.
+ */
+ErrorState *
+FwdState::makeConnectingError(const err_type type) const
+{
+ return errorCon(type, request->flags.need_validation ?
+ HTTP_GATEWAY_TIMEOUT : HTTP_SERVICE_UNAVAILABLE, request);
+}
+
static void
fwdStats(StoreEntry * s)
{