--------------------- PatchSet 11526 Date: 2007/07/15 06:16:42 Author: hno Branch: HEAD Tag: (none) Log: Changed most temporary & forwarding errors to return 504 Gateway Timeout This patch makes Squid more consistent in what HTTP status it returns on timeouts & forwarding errors. Members: src/HttpStatusLine.c:1.29->1.30 src/client_side.c:1.728->1.729 src/enums.h:1.238->1.239 src/forward.c:1.128->1.129 src/gopher.c:1.180->1.181 src/http.c:1.429->1.430 src/ssl.c:1.139->1.140 src/whois.c:1.23->1.24 Index: squid/src/HttpStatusLine.c =================================================================== RCS file: /cvsroot/squid/squid/src/HttpStatusLine.c,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- squid/src/HttpStatusLine.c 1 Apr 2007 12:51:01 -0000 1.29 +++ squid/src/HttpStatusLine.c 15 Jul 2007 06:16:42 -0000 1.30 @@ -1,6 +1,6 @@ /* - * $Id: HttpStatusLine.c,v 1.29 2007/04/01 12:51:01 serassio Exp $ + * $Id: HttpStatusLine.c,v 1.30 2007/07/15 06:16:42 hno Exp $ * * DEBUG: section 57 HTTP Status-line * AUTHOR: Alex Rousskov @@ -255,8 +255,8 @@ case HTTP_REQUEST_ENTITY_TOO_LARGE: p = "Request Entity Too Large"; break; - case HTTP_REQUEST_URI_TOO_LARGE: - p = "Request-URI Too Large"; + case HTTP_REQUEST_URI_TOO_LONG: + p = "Request-URI Too Long"; break; case HTTP_UNSUPPORTED_MEDIA_TYPE: p = "Unsupported Media Type"; Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid/squid/src/client_side.c,v retrieving revision 1.728 retrieving revision 1.729 diff -u -r1.728 -r1.729 --- squid/src/client_side.c 15 Jul 2007 05:41:19 -0000 1.728 +++ squid/src/client_side.c 15 Jul 2007 06:16:42 -0000 1.729 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.728 2007/07/15 05:41:19 hno Exp $ + * $Id: client_side.c,v 1.729 2007/07/15 06:16:42 hno Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -3870,7 +3870,7 @@ (int) conn->in.offset); debug(33, 1) ("Config 'request_header_max_size'= %ld bytes.\n", (long int) Config.maxRequestHeaderSize); - err = errorCon(ERR_TOO_BIG, HTTP_REQUEST_ENTITY_TOO_LARGE, NULL); + err = errorCon(ERR_TOO_BIG, HTTP_REQUEST_URI_TOO_LONG, NULL); err->src_addr = conn->peer.sin_addr; http = parseHttpRequestAbort(conn, "error:request-too-large"); /* add to the client request queue */ Index: squid/src/enums.h =================================================================== RCS file: /cvsroot/squid/squid/src/enums.h,v retrieving revision 1.238 retrieving revision 1.239 diff -u -r1.238 -r1.239 --- squid/src/enums.h 3 Mar 2007 18:23:45 -0000 1.238 +++ squid/src/enums.h 15 Jul 2007 06:16:42 -0000 1.239 @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.238 2007/03/03 18:23:45 hno Exp $ + * $Id: enums.h,v 1.239 2007/07/15 06:16:42 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -498,7 +498,7 @@ HTTP_LENGTH_REQUIRED = 411, HTTP_PRECONDITION_FAILED = 412, HTTP_REQUEST_ENTITY_TOO_LARGE = 413, - HTTP_REQUEST_URI_TOO_LARGE = 414, + HTTP_REQUEST_URI_TOO_LONG = 414, HTTP_UNSUPPORTED_MEDIA_TYPE = 415, HTTP_UNPROCESSABLE_ENTITY = 422, /* RFC2518 section 10.3 */ HTTP_LOCKED = 423, /* RFC2518 section 10.4 */ Index: squid/src/forward.c =================================================================== RCS file: /cvsroot/squid/squid/src/forward.c,v retrieving revision 1.128 retrieving revision 1.129 diff -u -r1.128 -r1.129 --- squid/src/forward.c 24 Apr 2007 14:59:28 -0000 1.128 +++ squid/src/forward.c 15 Jul 2007 06:16:42 -0000 1.129 @@ -1,6 +1,6 @@ /* - * $Id: forward.c,v 1.128 2007/04/24 14:59:28 hno Exp $ + * $Id: forward.c,v 1.129 2007/07/15 06:16:42 hno Exp $ * * DEBUG: section 17 Request Forwarding * AUTHOR: Duane Wessels @@ -218,7 +218,7 @@ return; } if (!fwdState->err && shutting_down) - fwdState->err = errorCon(ERR_SHUTTING_DOWN, HTTP_SERVICE_UNAVAILABLE, fwdState->request); + fwdState->err = errorCon(ERR_SHUTTING_DOWN, HTTP_GATEWAY_TIMEOUT, fwdState->request); fwdStateFree(fwdState); } @@ -246,7 +246,7 @@ return; default: debug(81, 1) ("fwdNegotiateSSL: Error negotiating SSL connection on FD %d: %s (%d/%d/%d)\n", fd, ERR_error_string(ERR_get_error(), NULL), ssl_error, ret, errno); - err = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request); + err = errorCon(ERR_CONNECT_FAIL, HTTP_BAD_GATEWAY, request); #ifdef EPROTO err->xerrno = EPROTO; #else @@ -347,13 +347,13 @@ fwdState->flags.dont_retry = 1; debug(17, 4) ("fwdConnectDone: Unknown host: %s\n", request->host); - err = errorCon(ERR_DNS_FAIL, HTTP_SERVICE_UNAVAILABLE, fwdState->request); + err = errorCon(ERR_DNS_FAIL, HTTP_GATEWAY_TIMEOUT, fwdState->request); err->dnsserver_msg = xstrdup(dns_error_message); fwdFail(fwdState, err); comm_close(server_fd); } else if (status != COMM_OK) { assert(fs); - err = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, fwdState->request); + err = errorCon(ERR_CONNECT_FAIL, HTTP_GATEWAY_TIMEOUT, fwdState->request); err->xerrno = errno; fwdFail(fwdState, err); if (fs->peer) @@ -651,7 +651,7 @@ { ErrorState *err; debug(17, 3) ("fwdStartFail: %s\n", storeUrl(fwdState->entry)); - err = errorCon(ERR_CANNOT_FORWARD, HTTP_SERVICE_UNAVAILABLE, fwdState->request); + err = errorCon(ERR_CANNOT_FORWARD, HTTP_GATEWAY_TIMEOUT, fwdState->request); err->xerrno = errno; fwdFail(fwdState, err); fwdStateFree(fwdState); @@ -849,7 +849,7 @@ #endif if (shutting_down) { /* more yuck */ - err = errorCon(ERR_SHUTTING_DOWN, HTTP_SERVICE_UNAVAILABLE, r); + err = errorCon(ERR_SHUTTING_DOWN, HTTP_GATEWAY_TIMEOUT, r); errorAppendEntry(e, err); return; } Index: squid/src/gopher.c =================================================================== RCS file: /cvsroot/squid/squid/src/gopher.c,v retrieving revision 1.180 retrieving revision 1.181 diff -u -r1.180 -r1.181 --- squid/src/gopher.c 26 Feb 2007 23:45:49 -0000 1.180 +++ squid/src/gopher.c 15 Jul 2007 06:16:42 -0000 1.181 @@ -1,6 +1,6 @@ /* - * $Id: gopher.c,v 1.180 2007/02/26 23:45:49 hno Exp $ + * $Id: gopher.c,v 1.181 2007/07/15 06:16:42 hno Exp $ * * DEBUG: section 10 Gopher * AUTHOR: Harvest Derived @@ -646,13 +646,13 @@ commSetSelect(fd, COMM_SELECT_READ, gopherReadReply, data, 0); } else { ErrorState *err; - err = errorCon(ERR_READ_ERROR, HTTP_INTERNAL_SERVER_ERROR, gopherState->fwdState->request); + err = errorCon(ERR_READ_ERROR, HTTP_BAD_GATEWAY, gopherState->fwdState->request); err->xerrno = errno; fwdFail(gopherState->fwdState, err); comm_close(fd); } } else if (len == 0 && entry->mem_obj->inmem_hi == 0) { - fwdFail(gopherState->fwdState, errorCon(ERR_ZERO_SIZE_OBJECT, HTTP_SERVICE_UNAVAILABLE, gopherState->fwdState->request)); + fwdFail(gopherState->fwdState, errorCon(ERR_ZERO_SIZE_OBJECT, HTTP_BAD_GATEWAY, gopherState->fwdState->request)); comm_close(fd); } else if (len == 0) { /* Connection closed; retrieval done. */ Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid/squid/src/http.c,v retrieving revision 1.429 retrieving revision 1.430 diff -u -r1.429 -r1.430 --- squid/src/http.c 14 Mar 2007 22:43:25 -0000 1.429 +++ squid/src/http.c 15 Jul 2007 06:16:42 -0000 1.430 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.429 2007/03/14 22:43:25 hno Exp $ + * $Id: http.c,v 1.430 2007/07/15 06:16:42 hno Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -312,7 +312,7 @@ case HTTP_FORBIDDEN: case HTTP_NOT_FOUND: case HTTP_METHOD_NOT_ALLOWED: - case HTTP_REQUEST_URI_TOO_LARGE: + case HTTP_REQUEST_URI_TOO_LONG: case HTTP_INTERNAL_SERVER_ERROR: case HTTP_NOT_IMPLEMENTED: case HTTP_BAD_GATEWAY: Index: squid/src/ssl.c =================================================================== RCS file: /cvsroot/squid/squid/src/ssl.c,v retrieving revision 1.139 retrieving revision 1.140 diff -u -r1.139 -r1.140 --- squid/src/ssl.c 24 Apr 2007 14:59:28 -0000 1.139 +++ squid/src/ssl.c 15 Jul 2007 06:16:42 -0000 1.140 @@ -1,6 +1,6 @@ /* - * $Id: ssl.c,v 1.139 2007/04/24 14:59:28 hno Exp $ + * $Id: ssl.c,v 1.140 2007/07/15 06:16:42 hno Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -424,7 +424,7 @@ if (status == COMM_ERR_DNS) { debug(26, 4) ("sslConnect: Unknown host: %s\n", sslState->host); comm_close(fd); - err = errorCon(ERR_DNS_FAIL, HTTP_NOT_FOUND, request); + err = errorCon(ERR_DNS_FAIL, HTTP_GATEWAY_TIMEOUT, request); *sslState->status_ptr = HTTP_NOT_FOUND; err->dnsserver_msg = xstrdup(dns_error_message); err->callback = sslErrorComplete; @@ -432,8 +432,8 @@ errorSend(sslState->client.fd, err); } else if (status != COMM_OK) { comm_close(fd); - err = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request); - *sslState->status_ptr = HTTP_SERVICE_UNAVAILABLE; + err = errorCon(ERR_CONNECT_FAIL, HTTP_GATEWAY_TIMEOUT, request); + *sslState->status_ptr = HTTP_GATEWAY_TIMEOUT; err->xerrno = errno; err->callback = sslErrorComplete; err->callback_data = sslState; @@ -470,8 +470,8 @@ hierarchyNote(&sslState->request->hier, sslState->servers->code, sslState->host); comm_close(fd); - err = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, request); - *sslState->status_ptr = HTTP_SERVICE_UNAVAILABLE; + err = errorCon(ERR_CONNECT_FAIL, HTTP_GATEWAY_TIMEOUT, request); + *sslState->status_ptr = HTTP_GATEWAY_TIMEOUT; err->xerrno = ETIMEDOUT; err->callback = sslErrorComplete; err->callback_data = sslState; @@ -611,8 +611,8 @@ peer *g = NULL; if (fs == NULL) { ErrorState *err; - err = errorCon(ERR_CANNOT_FORWARD, HTTP_SERVICE_UNAVAILABLE, sslState->request); - *sslState->status_ptr = HTTP_SERVICE_UNAVAILABLE; + err = errorCon(ERR_CANNOT_FORWARD, HTTP_GATEWAY_TIMEOUT, sslState->request); + *sslState->status_ptr = HTTP_GATEWAY_TIMEOUT; err->callback = sslErrorComplete; err->callback_data = sslState; errorSend(sslState->client.fd, err); Index: squid/src/whois.c =================================================================== RCS file: /cvsroot/squid/squid/src/whois.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- squid/src/whois.c 26 Feb 2007 09:11:11 -0000 1.23 +++ squid/src/whois.c 15 Jul 2007 06:16:42 -0000 1.24 @@ -1,6 +1,6 @@ /* - * $Id: whois.c,v 1.23 2007/02/26 09:11:11 hno Exp $ + * $Id: whois.c,v 1.24 2007/07/15 06:16:42 hno Exp $ * * DEBUG: section 75 WHOIS protocol * AUTHOR: Duane Wessels, Kostas Anagnostakis @@ -116,7 +116,7 @@ commSetSelect(fd, COMM_SELECT_READ, whoisReadReply, p, Config.Timeout.read); } else { ErrorState *err; - err = errorCon(ERR_READ_ERROR, HTTP_INTERNAL_SERVER_ERROR, p->fwd->request); + err = errorCon(ERR_READ_ERROR, HTTP_BAD_GATEWAY, p->fwd->request); err->xerrno = errno; fwdFail(p->fwd, err); comm_close(fd);