]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: http: Remove unused HTTP message templates
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 27 May 2020 08:11:59 +0000 (10:11 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 28 May 2020 13:07:20 +0000 (15:07 +0200)
HTTP_1XX, HTTP_3XX and HTTP_4XX message templates are no longer used. Only
HTTP_302 and HTTP_303 are used during configuration parsing by "errorloc" family
directives. So these templates are removed from the generic http code. And
HTTP_302 and HTTP_303 templates are moved as static strings in the function
parsing "errorloc" directives.

include/common/http.h
src/http.c
src/http_htx.c

index d31f5e915b850d3da8b6153844d48ab5a2480dc2..acf19903fbca661a4fec1e9b926da4df010cc1ff 100644 (file)
@@ -127,16 +127,6 @@ extern const char *http_err_msgs[HTTP_ERR_SIZE];
 extern const struct ist http_known_methods[HTTP_METH_OTHER];
 extern const uint8_t http_char_classes[256];
 
-extern const struct ist HTTP_100;
-extern const struct ist HTTP_103;
-extern const char *HTTP_301;
-extern const char *HTTP_302;
-extern const char *HTTP_303;
-extern const char *HTTP_307;
-extern const char *HTTP_308;
-extern const char *HTTP_401_fmt;
-extern const char *HTTP_407_fmt;
-
 enum http_meth_t find_http_meth(const char *str, const int len);
 int http_get_status_idx(unsigned int status);
 const char *http_get_reason(unsigned int status);
index a1e519793c67115ac0fb96b4d29171461be3172e..aaa6ddbe441f1452e73e501eab1cbde29dd6f111 100644 (file)
@@ -155,63 +155,6 @@ const unsigned char http_char_classes[256] = {
        [127] = HTTP_FLG_CTL,
 };
 
-const struct ist HTTP_100 = IST("HTTP/1.1 100 Continue\r\n\r\n");
-
-const struct ist HTTP_103 = IST("HTTP/1.1 103 Early Hints\r\n");
-
-/* Warning: no "connection" header is provided with the 3xx messages below */
-const char *HTTP_301 =
-       "HTTP/1.1 301 Moved Permanently\r\n"
-       "Content-length: 0\r\n"
-       "Location: "; /* not terminated since it will be concatenated with the URL */
-
-const char *HTTP_302 =
-       "HTTP/1.1 302 Found\r\n"
-       "Cache-Control: no-cache\r\n"
-       "Content-length: 0\r\n"
-       "Location: "; /* not terminated since it will be concatenated with the URL */
-
-/* same as 302 except that the browser MUST retry with the GET method */
-const char *HTTP_303 =
-       "HTTP/1.1 303 See Other\r\n"
-       "Cache-Control: no-cache\r\n"
-       "Content-length: 0\r\n"
-       "Location: "; /* not terminated since it will be concatenated with the URL */
-
-/* same as 302 except that the browser MUST retry with the same method */
-const char *HTTP_307 =
-       "HTTP/1.1 307 Temporary Redirect\r\n"
-       "Cache-Control: no-cache\r\n"
-       "Content-length: 0\r\n"
-       "Location: "; /* not terminated since it will be concatenated with the URL */
-
-/* same as 301 except that the browser MUST retry with the same method */
-const char *HTTP_308 =
-       "HTTP/1.1 308 Permanent Redirect\r\n"
-       "Content-length: 0\r\n"
-       "Location: "; /* not terminated since it will be concatenated with the URL */
-
-/* Warning: this one is an sprintf() fmt string, with <realm> as its only argument */
-const char *HTTP_401_fmt =
-       "HTTP/1.1 401 Unauthorized\r\n"
-       "Content-length: 112\r\n"
-       "Cache-Control: no-cache\r\n"
-       "Connection: close\r\n"
-       "Content-Type: text/html\r\n"
-       "WWW-Authenticate: Basic realm=\"%s\"\r\n"
-       "\r\n"
-       "<html><body><h1>401 Unauthorized</h1>\nYou need a valid user and password to access this content.\n</body></html>\n";
-
-const char *HTTP_407_fmt =
-       "HTTP/1.1 407 Unauthorized\r\n"
-       "Content-length: 112\r\n"
-       "Cache-Control: no-cache\r\n"
-       "Connection: close\r\n"
-       "Content-Type: text/html\r\n"
-       "Proxy-Authenticate: Basic realm=\"%s\"\r\n"
-       "\r\n"
-       "<html><body><h1>407 Unauthorized</h1>\nYou need a valid user and password to access this content.\n</body></html>\n";
-
 const int http_err_codes[HTTP_ERR_SIZE] = {
        [HTTP_ERR_200] = 200,  /* used by "monitor-uri" */
        [HTTP_ERR_400] = 400,
index 3137fbebbf37c3c855af5e401ad070e102da753c..7211a4de149683e3581bac86a9899f390b49377c 100644 (file)
@@ -1223,6 +1223,17 @@ struct buffer *http_parse_errorfile(int status, const char *file, char **errmsg)
  */
 struct buffer *http_parse_errorloc(int errloc, int status, const char *url, char **errmsg)
 {
+       static const char *HTTP_302 =
+               "HTTP/1.1 302 Found\r\n"
+               "Cache-Control: no-cache\r\n"
+               "Content-length: 0\r\n"
+               "Location: "; /* not terminated since it will be concatenated with the URL */
+       static const char *HTTP_303 =
+               "HTTP/1.1 303 See Other\r\n"
+               "Cache-Control: no-cache\r\n"
+               "Content-length: 0\r\n"
+               "Location: "; /* not terminated since it will be concatenated with the URL */
+
        struct buffer *buf = NULL;
        const char *msg;
        char *key = NULL, *err = NULL;