From 4e25eb61cd019e589ed5067eaaa8b4d95129044a Mon Sep 17 00:00:00 2001 From: phk Date: Tue, 28 Oct 2008 13:22:29 +0000 Subject: [PATCH] Factor the HTTP responsecodes into a file where we can find them. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3355 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_http.c | 42 +-------------- varnish-cache/include/http_response.h | 71 +++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 40 deletions(-) create mode 100644 varnish-cache/include/http_response.h diff --git a/varnish-cache/bin/varnishd/cache_http.c b/varnish-cache/bin/varnishd/cache_http.c index c93a37a9..18ba655a 100644 --- a/varnish-cache/bin/varnishd/cache_http.c +++ b/varnish-cache/bin/varnishd/cache_http.c @@ -98,46 +98,8 @@ static struct http_msg { unsigned nbr; const char *txt; } http_msg[] = { - { 101, "Switching Protocols" }, - { 200, "OK" }, - { 201, "Created" }, - { 202, "Accepted" }, - { 203, "Non-Authoritative Information" }, - { 204, "No Content" }, - { 205, "Reset Content" }, - { 206, "Partial Content" }, - { 300, "Multiple Choices" }, - { 301, "Moved Permanently" }, - { 302, "Found" }, - { 303, "See Other" }, - { 304, "Not Modified" }, - { 305, "Use Proxy" }, - { 306, "(Unused)" }, - { 307, "Temporary Redirect" }, - { 400, "Bad Request" }, - { 401, "Unauthorized" }, - { 402, "Payment Required" }, - { 403, "Forbidden" }, - { 404, "Not Found" }, - { 405, "Method Not Allowed" }, - { 406, "Not Acceptable" }, - { 407, "Proxy Authentication Required" }, - { 408, "Request Timeout" }, - { 409, "Conflict" }, - { 410, "Gone" }, - { 411, "Length Required" }, - { 412, "Precondition Failed" }, - { 413, "Request Entity Too Large" }, - { 414, "Request-URI Too Long" }, - { 415, "Unsupported Media Type" }, - { 416, "Requested Range Not Satisfiable" }, - { 417, "Expectation Failed" }, - { 500, "Internal Server Error" }, - { 501, "Not Implemented" }, - { 502, "Bad Gateway" }, - { 503, "Service Unavailable" }, - { 504, "Gateway Timeout" }, - { 505, "HTTP Version Not Supported" }, +#define HTTP_RESP(n, t) { n, t}, +#include "http_response.h" { 0, NULL } }; diff --git a/varnish-cache/include/http_response.h b/varnish-cache/include/http_response.h new file mode 100644 index 00000000..e9fd9c91 --- /dev/null +++ b/varnish-cache/include/http_response.h @@ -0,0 +1,71 @@ +/*- + * Copyright (c) 2006 Verdens Gang AS + * Copyright (c) 2006-2008 Linpro AS + * All rights reserved. + * + * Author: Poul-Henning Kamp + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + */ + +HTTP_RESP(101, "Switching Protocols") +HTTP_RESP(200, "OK") +HTTP_RESP(201, "Created") +HTTP_RESP(202, "Accepted") +HTTP_RESP(203, "Non-Authoritative Information") +HTTP_RESP(204, "No Content") +HTTP_RESP(205, "Reset Content") +HTTP_RESP(206, "Partial Content") +HTTP_RESP(300, "Multiple Choices") +HTTP_RESP(301, "Moved Permanently") +HTTP_RESP(302, "Found") +HTTP_RESP(303, "See Other") +HTTP_RESP(304, "Not Modified") +HTTP_RESP(305, "Use Proxy") +HTTP_RESP(306, "(Unused)") +HTTP_RESP(307, "Temporary Redirect") +HTTP_RESP(400, "Bad Request") +HTTP_RESP(401, "Unauthorized") +HTTP_RESP(402, "Payment Required") +HTTP_RESP(403, "Forbidden") +HTTP_RESP(404, "Not Found") +HTTP_RESP(405, "Method Not Allowed") +HTTP_RESP(406, "Not Acceptable") +HTTP_RESP(407, "Proxy Authentication Required") +HTTP_RESP(408, "Request Timeout") +HTTP_RESP(409, "Conflict") +HTTP_RESP(410, "Gone") +HTTP_RESP(411, "Length Required") +HTTP_RESP(412, "Precondition Failed") +HTTP_RESP(413, "Request Entity Too Large") +HTTP_RESP(414, "Request-URI Too Long") +HTTP_RESP(415, "Unsupported Media Type") +HTTP_RESP(416, "Requested Range Not Satisfiable") +HTTP_RESP(417, "Expectation Failed") +HTTP_RESP(500, "Internal Server Error") +HTTP_RESP(501, "Not Implemented") +HTTP_RESP(502, "Bad Gateway") +HTTP_RESP(503, "Service Unavailable") +HTTP_RESP(504, "Gateway Timeout") +HTTP_RESP(505, "HTTP Version Not Supported") -- 2.39.5